fixed checking if state is correct in executive tests

This commit is contained in:
debris 2016-03-24 16:40:52 +01:00
parent 1aa34e9dd4
commit a7ce6fca9e

View File

@ -25,7 +25,6 @@ use ethereum;
use externalities::*; use externalities::*;
use substate::*; use substate::*;
use tests::helpers::*; use tests::helpers::*;
use state_diff::StateDiff;
use ethjson; use ethjson;
struct TestEngineFrontier { struct TestEngineFrontier {
@ -238,8 +237,19 @@ fn do_json_test_for(vm_type: &VMType, json_data: &[u8]) -> Vec<String> {
let vm_output: Option<Vec<u8>> = vm.output.map(Into::into); let vm_output: Option<Vec<u8>> = vm.output.map(Into::into);
fail_unless(Some(output) == vm_output, "output is incorrect"); fail_unless(Some(output) == vm_output, "output is incorrect");
let diff = StateDiff::diff_pod(&state.to_pod(), &From::from(vm.post_state.unwrap())); for (address, account) in vm.post_state.unwrap().into_iter() {
fail_unless(diff.is_empty(), format!("diff should be empty!: {:?}", diff).as_ref()); let address = address.into();
let code: Vec<u8> = account.code.into();
fail_unless(state.code(&address).unwrap_or_else(Vec::new) == code, "code is incorrect");
fail_unless(state.balance(&address) == account.balance.into(), "balance is incorrect");
fail_unless(state.nonce(&address) == account.nonce.into(), "nonce is incorrect");
account.storage.into_iter().foreach(|(k, v)| {
let key: U256 = k.into();
let value: U256 = v.into();
fail_unless(state.storage_at(&address, &From::from(key)) == From::from(value), "storage is incorrect");
});
}
let calls: Option<Vec<CallCreate>> = vm.calls.map(|c| c.into_iter().map(From::from).collect()); let calls: Option<Vec<CallCreate>> = vm.calls.map(|c| c.into_iter().map(From::from).collect());
fail_unless(Some(callcreates) == calls, "callcreates does not match"); fail_unless(Some(callcreates) == calls, "callcreates does not match");
} }