Updated unit tests for changes in builder
This commit is contained in:
parent
4855d9304e
commit
a14745dac5
@ -113,7 +113,7 @@ var (
|
||||
Nonce: 1,
|
||||
Balance: big.NewInt(0),
|
||||
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
|
||||
Root: crypto.Keccak256Hash(slot0StorageLeafRootNode),
|
||||
Root: crypto.Keccak256Hash(block5StorageBranchRootNode),
|
||||
})
|
||||
contractAccountAtBlock5LeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"),
|
||||
@ -163,7 +163,7 @@ var (
|
||||
})
|
||||
account1AtBlock5, _ = rlp.EncodeToBytes(types.StateAccount{
|
||||
Nonce: 2,
|
||||
Balance: big.NewInt(2999566008847709960),
|
||||
Balance: big.NewInt(2999586469962854280),
|
||||
CodeHash: test_helpers.NullCodeHash.Bytes(),
|
||||
Root: test_helpers.EmptyContractRoot,
|
||||
})
|
||||
@ -173,7 +173,7 @@ var (
|
||||
})
|
||||
account1AtBlock6, _ = rlp.EncodeToBytes(types.StateAccount{
|
||||
Nonce: 3,
|
||||
Balance: big.NewInt(2999537516847709960),
|
||||
Balance: big.NewInt(2999557977962854280),
|
||||
CodeHash: test_helpers.NullCodeHash.Bytes(),
|
||||
Root: test_helpers.EmptyContractRoot,
|
||||
})
|
||||
@ -214,7 +214,7 @@ var (
|
||||
})
|
||||
account2AtBlock6, _ = rlp.EncodeToBytes(types.StateAccount{
|
||||
Nonce: 0,
|
||||
Balance: big.NewInt(6000063293259748636),
|
||||
Balance: big.NewInt(6000063258066544204),
|
||||
CodeHash: test_helpers.NullCodeHash.Bytes(),
|
||||
Root: test_helpers.EmptyContractRoot,
|
||||
})
|
||||
@ -278,8 +278,8 @@ var (
|
||||
bankAccountAtBlock4,
|
||||
})
|
||||
bankAccountAtBlock5, _ = rlp.EncodeToBytes(types.StateAccount{
|
||||
Nonce: 7,
|
||||
Balance: big.NewInt(999805027999990000),
|
||||
Nonce: 8,
|
||||
Balance: big.NewInt(999761283999990000),
|
||||
CodeHash: test_helpers.NullCodeHash.Bytes(),
|
||||
Root: test_helpers.EmptyContractRoot,
|
||||
})
|
||||
@ -460,6 +460,25 @@ var (
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
})
|
||||
block5StorageBranchRootNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
crypto.Keccak256(slot0StorageLeafNode),
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
crypto.Keccak256(slot3StorageLeafNode),
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -1272,15 +1291,14 @@ func TestBuilderWithRemovedAccountAndStorage(t *testing.T) {
|
||||
StorageNodes: []types2.StorageNode{
|
||||
{
|
||||
Path: []byte{},
|
||||
NodeType: types2.Leaf,
|
||||
NodeValue: slot0StorageLeafRootNode,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
NodeType: types2.Branch,
|
||||
NodeValue: block5StorageBranchRootNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
NodeValue: []byte{},
|
||||
Path: []byte{'\x0c'},
|
||||
NodeType: types2.Leaf,
|
||||
LeafKey: slot3StorageKey.Bytes(),
|
||||
NodeValue: slot3StorageLeafNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x04'},
|
||||
@ -1319,11 +1337,29 @@ func TestBuilderWithRemovedAccountAndStorage(t *testing.T) {
|
||||
StorageNodes: emptyStorage,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x06'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: contractLeafKey,
|
||||
NodeValue: []byte{},
|
||||
StorageNodes: emptyStorage,
|
||||
Path: []byte{'\x06'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: contractLeafKey,
|
||||
NodeValue: []byte{},
|
||||
StorageNodes: []types2.StorageNode{
|
||||
{
|
||||
Path: []byte{},
|
||||
NodeType: types2.Removed,
|
||||
NodeValue: []byte{},
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
NodeValue: []byte{},
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0c'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot3StorageKey.Bytes(),
|
||||
NodeValue: []byte{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0c'},
|
||||
@ -1467,16 +1503,10 @@ func TestBuilderWithRemovedAccountAndStorageWithoutIntermediateNodes(t *testing.
|
||||
NodeValue: contractAccountAtBlock5LeafNode,
|
||||
StorageNodes: []types2.StorageNode{
|
||||
{
|
||||
Path: []byte{},
|
||||
Path: []byte{'\x0c'},
|
||||
NodeType: types2.Leaf,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
NodeValue: slot0StorageLeafRootNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
NodeValue: []byte{},
|
||||
LeafKey: slot3StorageKey.Bytes(),
|
||||
NodeValue: slot3StorageLeafNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x04'},
|
||||
@ -1513,6 +1543,20 @@ func TestBuilderWithRemovedAccountAndStorageWithoutIntermediateNodes(t *testing.
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: contractLeafKey,
|
||||
NodeValue: []byte{},
|
||||
StorageNodes: []types2.StorageNode{
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
NodeValue: []byte{},
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0c'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot3StorageKey.Bytes(),
|
||||
NodeValue: []byte{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0c'},
|
||||
@ -1754,16 +1798,10 @@ func TestBuilderWithRemovedWatchedAccount(t *testing.T) {
|
||||
NodeValue: contractAccountAtBlock5LeafNode,
|
||||
StorageNodes: []types2.StorageNode{
|
||||
{
|
||||
Path: []byte{},
|
||||
Path: []byte{'\x0c'},
|
||||
NodeType: types2.Leaf,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
NodeValue: slot0StorageLeafRootNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
NodeValue: []byte{},
|
||||
LeafKey: slot3StorageKey.Bytes(),
|
||||
NodeValue: slot3StorageLeafNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x04'},
|
||||
@ -1800,6 +1838,20 @@ func TestBuilderWithRemovedWatchedAccount(t *testing.T) {
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: contractLeafKey,
|
||||
NodeValue: []byte{},
|
||||
StorageNodes: []types2.StorageNode{
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
NodeValue: []byte{},
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0c'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot3StorageKey.Bytes(),
|
||||
NodeValue: []byte{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0e'},
|
||||
@ -2019,6 +2071,22 @@ func TestBuilderWithMovedAccount(t *testing.T) {
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: contractLeafKey,
|
||||
NodeValue: []byte{},
|
||||
StorageNodes: []types2.StorageNode{
|
||||
{
|
||||
Path: []byte{},
|
||||
NodeType: types2.Removed,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0b'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot1StorageKey.Bytes(),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x00'},
|
||||
@ -2144,6 +2212,18 @@ func TestBuilderWithMovedAccountOnlyLeafs(t *testing.T) {
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: contractLeafKey,
|
||||
NodeValue: []byte{},
|
||||
StorageNodes: []types2.StorageNode{
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot0StorageKey.Bytes(),
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0b'},
|
||||
NodeType: types2.Removed,
|
||||
LeafKey: slot1StorageKey.Bytes(),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x00'},
|
||||
|
@ -106,13 +106,17 @@ func TestChainGen(i int, block *core.BlockGen) {
|
||||
block.AddTx(tx3)
|
||||
case 4:
|
||||
// Block 5 has one tx from bankAccount to the contract, that transfers no value
|
||||
// It sets the remaining storage value to zero
|
||||
// It sets the one storage value to zero and the other to new value.
|
||||
// Block 5 is mined by Account1Addr
|
||||
block.SetCoinbase(Account1Addr)
|
||||
data := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000")
|
||||
data1 := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000")
|
||||
data2 := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003")
|
||||
nonce := block.TxNonce(TestBankAddress)
|
||||
tx, _ := types.SignTx(types.NewTransaction(nonce, ContractAddr, big.NewInt(0), 100000, big.NewInt(params.InitialBaseFee), data), signer, TestBankKey)
|
||||
block.AddTx(tx)
|
||||
tx1, _ := types.SignTx(types.NewTransaction(nonce, ContractAddr, big.NewInt(0), 100000, big.NewInt(params.InitialBaseFee), data1), signer, TestBankKey)
|
||||
nonce++
|
||||
tx2, _ := types.SignTx(types.NewTransaction(nonce, ContractAddr, big.NewInt(0), 100000, big.NewInt(params.InitialBaseFee), data2), signer, TestBankKey)
|
||||
block.AddTx(tx1)
|
||||
block.AddTx(tx2)
|
||||
case 5:
|
||||
// Block 6 has a tx from Account1Key which self-destructs the contract, it transfers no value
|
||||
// Block 6 is mined by Account2Addr
|
||||
|
Loading…
Reference in New Issue
Block a user