makeTestState create a sample test state to test node-wise reconstruction.
()
| 37 | |
| 38 | // makeTestState create a sample test state to test node-wise reconstruction. |
| 39 | func makeTestState() (Database, common.Hash, []*testAccount) { |
| 40 | // Create an empty state |
| 41 | db := NewDatabase(database.NewMemDatabase()) |
| 42 | state, _ := New(common.Hash{}, db) |
| 43 | |
| 44 | // Fill it with some arbitrary data |
| 45 | accounts := []*testAccount{} |
| 46 | for i := byte(0); i < 96; i++ { |
| 47 | obj := state.GetOrNewStateObject(common.BytesToAddress([]byte{i})) |
| 48 | acc := &testAccount{address: common.BytesToAddress([]byte{i})} |
| 49 | |
| 50 | obj.AddBalance(big.NewInt(int64(11 * i))) |
| 51 | acc.balance = big.NewInt(int64(11 * i)) |
| 52 | |
| 53 | obj.SetNonce(uint64(42 * i)) |
| 54 | acc.nonce = uint64(42 * i) |
| 55 | |
| 56 | if i%3 == 0 { |
| 57 | obj.SetCode(crypto.Keccak256Hash([]byte{i, i, i, i, i}), []byte{i, i, i, i, i}) |
| 58 | acc.code = []byte{i, i, i, i, i} |
| 59 | } |
| 60 | state.updateStateObject(obj) |
| 61 | accounts = append(accounts, acc) |
| 62 | } |
| 63 | root, _ := state.Commit(false) |
| 64 | |
| 65 | // Return the generated state |
| 66 | return db, root, accounts |
| 67 | } |
| 68 | |
| 69 | // checkStateAccounts cross references a reconstructed state with an expected |
| 70 | // account array. |
no test coverage detected