public void Test_out_of_gas_existing_account() { byte[] salt = { 4, 5, 6 }; byte[] deployedCode = { 1, 2, 3 }; byte[] initCode = Prepare.EvmCode .ForInitOf(deployedCode).Done; byte[] createCode = Prepare.EvmCode .Create2(initCode, salt, 0).Done; Address expectedAddress = ContractAddress.From(TestItem.AddressC, salt.PadLeft(32).AsSpan(), initCode.AsSpan()); TestState.CreateAccount(expectedAddress, 1.Ether()); TestState.CreateAccount(TestItem.AddressC, 1.Ether()); Keccak createCodeHash = TestState.UpdateCode(createCode); TestState.UpdateCodeHash(TestItem.AddressC, createCodeHash, Spec); byte[] code = Prepare.EvmCode .Call(TestItem.AddressC, 32100) .Done; Execute(code); TestState.GetAccount(expectedAddress).Should().NotBeNull(); TestState.GetAccount(expectedAddress).Balance.Should().Be(1.Ether()); AssertEip1014(expectedAddress, Bytes.Empty); }
public void Test_out_of_gas_existing_account_with_storage() { byte[] salt = { 4, 5, 6 }; byte[] deployedCode = { 1, 2, 3 }; byte[] initCode = Prepare.EvmCode .ForInitOf(deployedCode).Done; byte[] createCode = Prepare.EvmCode .Create2(initCode, salt, 0).Done; Address expectedAddress = ContractAddress.From(TestItem.AddressC, salt.PadLeft(32).AsSpan(), initCode.AsSpan()); TestState.CreateAccount(expectedAddress, 1.Ether()); Storage.Set(new StorageCell(expectedAddress, 1), new byte[] { 1, 2, 3, 4, 5 }); Storage.Commit(); Storage.CommitTrees(); TestState.Commit(Spec); TestState.CommitTree(); Keccak storageRoot = TestState.GetAccount(expectedAddress).StorageRoot; storageRoot.Should().NotBe(PatriciaTree.EmptyTreeHash); TestState.CreateAccount(TestItem.AddressC, 1.Ether()); Keccak createCodeHash = TestState.UpdateCode(createCode); TestState.UpdateCodeHash(TestItem.AddressC, createCodeHash, Spec); byte[] code = Prepare.EvmCode .Call(TestItem.AddressC, 32100) .Done; Execute(code); TestState.GetAccount(expectedAddress).Should().NotBeNull(); TestState.GetAccount(expectedAddress).Balance.Should().Be(1.Ether()); TestState.GetAccount(expectedAddress).StorageRoot.Should().Be(storageRoot); AssertEip1014(expectedAddress, Bytes.Empty); }