Fix state not using "account_starting_nonce" (#1830)

* failng test

* use account_starting_nonce instead of zero

* simplier test

* jsons are getting closer

* incorrect test client and incorrect tests fix

* null_morden is using 0x0 starting nonce

* replaced json with the correct one

* superwhatever line
This commit is contained in:
Nikolay Volf
2016-08-04 19:17:39 +03:00
committed by Gav Wood
parent 25aabe6e52
commit aa59aa439d
4 changed files with 69 additions and 3 deletions

View File

@@ -310,7 +310,7 @@ impl BlockChainClient for TestBlockChainClient {
fn nonce(&self, address: &Address, id: BlockID) -> Option<U256> {
match id {
BlockID::Latest => Some(self.nonces.read().get(address).cloned().unwrap_or_else(U256::zero)),
BlockID::Latest => Some(self.nonces.read().get(address).cloned().unwrap_or(self.spec.params.account_start_nonce)),
_ => None,
}
}

View File

@@ -175,7 +175,7 @@ impl State {
/// Get the nonce of account `a`.
pub fn nonce(&self, a: &Address) -> U256 {
self.ensure_cached(a, false,
|a| a.as_ref().map_or(U256::zero(), |account| *account.nonce()))
|a| a.as_ref().map_or(self.account_start_nonce, |account| *account.nonce()))
}
/// Mutate storage of account `address` so that it is `value` for `key`.