Skip to content

Commit

Permalink
fixed error 4 tests failing
Browse files Browse the repository at this point in the history
  • Loading branch information
max-wickham committed Mar 26, 2024
1 parent c2c2e4e commit 9adb1de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
17 changes: 6 additions & 11 deletions tests/mocks/mock_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub struct Contract {
pub code: Vec<u8>,
pub nonce: U256,
pub storage: BTreeMap<H256, H256>,
pub active_storage: BTreeMap<H256, H256>,
pub is_deleted: bool,
pub is_cold: bool,
pub hot_keys: HashSet<U256>,
Expand Down Expand Up @@ -81,11 +80,11 @@ impl MockRuntime {
(H160::from(u256_to_h256(*address)), {
println!("");
println!("address: {:x}", address);
println!("storage: {:?}", contract.active_storage);
println!("storage: {:?}", contract.storage);
let encoded_contract = rlp::encode(&RLPContract {
storage_root_hash: ethereum::util::sec_trie_root(
contract
.active_storage
.storage
.iter()
.map(|(key, value)| (key, rlp::encode(&h256_to_u256(*value)))),
),
Expand Down Expand Up @@ -217,9 +216,9 @@ impl Runtime for MockRuntime {
.unwrap()
.storage
.insert(u256_to_h256(index), value);
for (address, contract) in &self.current_context.as_ref().unwrap().contracts {
println!("Storage: {:?}", contract.storage);
}
// for (address, contract) in &self.current_context.as_ref().unwrap().contracts {
// println!("Storage: {:?}", contract.storage);
// }
}
fn mark_delete(&mut self, address: U256) {
self.current_context
Expand Down Expand Up @@ -304,18 +303,14 @@ impl Runtime for MockRuntime {
};
}
fn merge_context(&mut self) {
println!("Merging Context");

match mem::take(&mut self.current_context) {
Some(mut context) => {
for (address, contract) in &context.contracts {
println!("Storage: {:?}", contract.storage);
}
match &mut context.prev_context {
Some(prev_context) => {
prev_context.contracts = context.contracts;
}
None => {
println!("Setting Contracts");
self.contracts = context.contracts;
}
}
Expand Down
18 changes: 10 additions & 8 deletions tests/official_tests/official_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub fn run_test(test: &TestState, debug: bool) {
code: contract.code.0.clone(),
nonce: contract.nonce,
storage: contract.storage.clone(),
active_storage: contract.storage.clone(),
is_deleted: false,
is_cold: true,
hot_keys: HashSet::new(),
Expand All @@ -73,7 +72,6 @@ pub fn run_test(test: &TestState, debug: bool) {
code: vec![],
nonce: U256::zero(),
storage: BTreeMap::new(),
active_storage: BTreeMap::new(),
is_deleted: false,
is_cold: true,
hot_keys: HashSet::new(),
Expand Down Expand Up @@ -118,18 +116,22 @@ pub fn run_test(test: &TestState, debug: bool) {
Some(_) => "Exists",
_ => "Doesn't Exist",
});
for (address, contract) in &runtime.contracts {
println!("Address: {:x}", address);
println!("Storage: {:?}", contract.storage);
}
// Debug the balances
assert_eq!(runtime.state_root_hash(), test.post.hash);
}

// generate_official_tests_from_folder!(
// "./tests/official_tests/tests/GeneralStateTests/VMTests/vmArithmeticTest"
// );
generate_official_tests_from_folder!(
"./tests/official_tests/tests/GeneralStateTests/VMTests/vmArithmeticTest"
);

// generate_official_tests_from_folder!(
// "./tests/official_tests/tests/GeneralStateTests/stRandom"
// );

generate_official_tests_from_file!(
"./tests/official_tests/tests/GeneralStateTests/VMTests/vmArithmeticTest/mul.json"
);
// generate_official_tests_from_file!(
// "./tests/official_tests/tests/GeneralStateTests/VMTests/vmArithmeticTest/mul.json"
// );

0 comments on commit 9adb1de

Please sign in to comment.