Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
172d6289
Commit
172d6289
authored
Oct 02, 2020
by
Kelvin Fichter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lots of tests
parent
eabb5dd8
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
77 additions
and
181 deletions
+77
-181
Lib_OVMCodec.sol
...acts/optimistic-ethereum/libraries/codec/Lib_OVMCodec.sol
+5
-5
Lib_RLPWriter.sol
...racts/optimistic-ethereum/libraries/rlp/Lib_RLPWriter.sol
+19
-19
Lib_MerkleTrie.sol
...cts/optimistic-ethereum/libraries/trie/Lib_MerkleTrie.sol
+7
-7
Lib_EthUtils.sol
...acts/optimistic-ethereum/libraries/utils/Lib_EthUtils.sol
+3
-3
TestLib_RLPWriter.sol
...tracts/contracts/test-libraries/rlp/TestLib_RLPWriter.sol
+14
-14
package.json
packages/contracts/package.json
+1
-1
OVM_StateManager.spec.ts
...cts/test/contracts/OVM/execution/OVM_StateManager.spec.ts
+3
-3
OVM_StateTransitioner.spec.ts
.../contracts/OVM/verification/OVM_StateTransitioner.spec.ts
+21
-13
Lib_RLPWriter.spec.ts
...tracts/test/contracts/libraries/rlp/Lib_RLPWriter.spec.ts
+4
-4
Lib_EthMerkleTrie.spec.ts
...s/test/contracts/libraries/trie/Lib_EthMerkleTrie.spec.ts
+0
-112
No files found.
packages/contracts/contracts/optimistic-ethereum/libraries/codec/Lib_OVMCodec.sol
View file @
172d6289
...
...
@@ -205,12 +205,12 @@ library Lib_OVMCodec {
// Unfortunately we can't create this array outright because
// RLPWriter.encodeList will reject fixed-size arrays. Assigning
// index-by-index circumvents this issue.
raw[0] = Lib_RLPWriter.
encod
eUint(_account.nonce);
raw[1] = Lib_RLPWriter.
encod
eUint(_account.balance);
raw[2] = _account.storageRoot == 0 ? RLP_NULL_BYTES : Lib_RLPWriter.
encod
eBytes(abi.encodePacked(_account.storageRoot));
raw[3] = _account.codeHash == 0 ? RLP_NULL_BYTES : Lib_RLPWriter.
encod
eBytes(abi.encodePacked(_account.codeHash));
raw[0] = Lib_RLPWriter.
writ
eUint(_account.nonce);
raw[1] = Lib_RLPWriter.
writ
eUint(_account.balance);
raw[2] = _account.storageRoot == 0 ? RLP_NULL_BYTES : Lib_RLPWriter.
writ
eBytes(abi.encodePacked(_account.storageRoot));
raw[3] = _account.codeHash == 0 ? RLP_NULL_BYTES : Lib_RLPWriter.
writ
eBytes(abi.encodePacked(_account.codeHash));
return Lib_RLPWriter.
encod
eList(raw);
return Lib_RLPWriter.
writ
eList(raw);
}
/**
...
...
packages/contracts/contracts/optimistic-ethereum/libraries/rlp/Lib_RLPWriter.sol
View file @
172d6289
...
...
@@ -20,7 +20,7 @@ library Lib_RLPWriter {
* @param _in The byte string to encode.
* @return _out The RLP encoded string in bytes.
*/
function
encod
eBytes(
function
writ
eBytes(
bytes memory _in
)
internal
...
...
@@ -34,7 +34,7 @@ library Lib_RLPWriter {
if (_in.length == 1 && uint8(_in[0]) < 128) {
encoded = _in;
} else {
encoded = Lib_BytesUtils.concat(
encod
eLength(_in.length, 128), _in);
encoded = Lib_BytesUtils.concat(
_writ
eLength(_in.length, 128), _in);
}
return encoded;
...
...
@@ -45,7 +45,7 @@ library Lib_RLPWriter {
* @param _in The list of RLP encoded byte strings.
* @return _out The RLP encoded list of items in bytes.
*/
function
encod
eList(
function
writ
eList(
bytes[] memory _in
)
internal
...
...
@@ -54,8 +54,8 @@ library Lib_RLPWriter {
bytes memory _out
)
{
bytes memory list = flatten(_in);
return Lib_BytesUtils.concat(
encod
eLength(list.length, 192), list);
bytes memory list =
_
flatten(_in);
return Lib_BytesUtils.concat(
_writ
eLength(list.length, 192), list);
}
/**
...
...
@@ -63,7 +63,7 @@ library Lib_RLPWriter {
* @param _in The string to encode.
* @return _out The RLP encoded string in bytes.
*/
function
encod
eString(
function
writ
eString(
string memory _in
)
internal
...
...
@@ -72,7 +72,7 @@ library Lib_RLPWriter {
bytes memory _out
)
{
return
encod
eBytes(bytes(_in));
return
writ
eBytes(bytes(_in));
}
/**
...
...
@@ -80,7 +80,7 @@ library Lib_RLPWriter {
* @param _in The address to encode.
* @return _out The RLP encoded address in bytes.
*/
function
encod
eAddress(
function
writ
eAddress(
address _in
)
internal
...
...
@@ -97,7 +97,7 @@ library Lib_RLPWriter {
inputBytes := m
}
return
encod
eBytes(inputBytes);
return
writ
eBytes(inputBytes);
}
/**
...
...
@@ -105,7 +105,7 @@ library Lib_RLPWriter {
* @param _in The uint to encode.
* @return _out The RLP encoded uint in bytes.
*/
function
encod
eUint(
function
writ
eUint(
uint _in
)
internal
...
...
@@ -114,7 +114,7 @@ library Lib_RLPWriter {
bytes memory _out
)
{
return
encodeBytes(
toBinary(_in));
return
writeBytes(_
toBinary(_in));
}
/**
...
...
@@ -122,7 +122,7 @@ library Lib_RLPWriter {
* @param _in The int to encode.
* @return _out The RLP encoded int in bytes.
*/
function
encod
eInt(
function
writ
eInt(
int _in
)
internal
...
...
@@ -131,7 +131,7 @@ library Lib_RLPWriter {
bytes memory _out
)
{
return
encod
eUint(uint(_in));
return
writ
eUint(uint(_in));
}
/**
...
...
@@ -139,7 +139,7 @@ library Lib_RLPWriter {
* @param _in The bool to encode.
* @return _out The RLP encoded bool in bytes.
*/
function
encod
eBool(
function
writ
eBool(
bool _in
)
internal
...
...
@@ -164,7 +164,7 @@ library Lib_RLPWriter {
* @param _offset 128 if item is string, 192 if item is list.
* @return _encoded RLP encoded bytes.
*/
function
encod
eLength(
function
_writ
eLength(
uint _len,
uint _offset
)
...
...
@@ -203,7 +203,7 @@ library Lib_RLPWriter {
* @param _x The integer to encode.
* @return _binary RLP encoded bytes.
*/
function toBinary(
function
_
toBinary(
uint _x
)
private
...
...
@@ -239,7 +239,7 @@ library Lib_RLPWriter {
* @param _src Source location.
* @param _len Length of memory to copy.
*/
function memcpy(
function
_
memcpy(
uint _dest,
uint _src,
uint _len
...
...
@@ -273,7 +273,7 @@ library Lib_RLPWriter {
* @param _list List of byte strings to flatten.
* @return _flattened The flattened byte string.
*/
function flatten(
function
_
flatten(
bytes[] memory _list
)
private
...
...
@@ -302,7 +302,7 @@ library Lib_RLPWriter {
uint listPtr;
assembly { listPtr := add(item, 0x20)}
memcpy(flattenedPtr, listPtr, item.length);
_
memcpy(flattenedPtr, listPtr, item.length);
flattenedPtr += _list[i].length;
}
...
...
packages/contracts/contracts/optimistic-ethereum/libraries/trie/Lib_MerkleTrie.sol
View file @
172d6289
...
...
@@ -739,7 +739,7 @@ library Lib_MerkleTrie {
TrieNode memory _node
)
{
bytes memory encoded = Lib_RLPWriter.
encod
eList(_raw);
bytes memory encoded = Lib_RLPWriter.
writ
eList(_raw);
return TrieNode({
encoded: encoded,
...
...
@@ -786,8 +786,8 @@ library Lib_MerkleTrie {
{
bytes[] memory raw = new bytes[](2);
bytes memory key = _addHexPrefix(_key, false);
raw[0] = Lib_RLPWriter.
encod
eBytes(Lib_BytesUtils.fromNibbles(key));
raw[1] = Lib_RLPWriter.
encod
eBytes(_value);
raw[0] = Lib_RLPWriter.
writ
eBytes(Lib_BytesUtils.fromNibbles(key));
raw[1] = Lib_RLPWriter.
writ
eBytes(_value);
return _makeNode(raw);
}
...
...
@@ -812,8 +812,8 @@ library Lib_MerkleTrie {
{
bytes[] memory raw = new bytes[](2);
bytes memory key = _addHexPrefix(_key, true);
raw[0] = Lib_RLPWriter.
encod
eBytes(Lib_BytesUtils.fromNibbles(key));
raw[1] = Lib_RLPWriter.
encod
eBytes(_value);
raw[0] = Lib_RLPWriter.
writ
eBytes(Lib_BytesUtils.fromNibbles(key));
raw[1] = Lib_RLPWriter.
writ
eBytes(_value);
return _makeNode(raw);
}
...
...
@@ -851,7 +851,7 @@ library Lib_MerkleTrie {
TrieNode memory _updatedNode
)
{
bytes memory encoded = Lib_RLPWriter.
encod
eBytes(_value);
bytes memory encoded = Lib_RLPWriter.
writ
eBytes(_value);
_branch.decoded[_branch.decoded.length - 1] = Lib_RLPReader.toRLPItem(encoded);
return _makeNode(_branch.decoded);
}
...
...
@@ -874,7 +874,7 @@ library Lib_MerkleTrie {
TrieNode memory _updatedNode
)
{
bytes memory encoded = _value.length < 32 ? _value : Lib_RLPWriter.
encod
eBytes(_value);
bytes memory encoded = _value.length < 32 ? _value : Lib_RLPWriter.
writ
eBytes(_value);
_branch.decoded[_index] = Lib_RLPReader.toRLPItem(encoded);
return _makeNode(_branch.decoded);
}
...
...
packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_EthUtils.sol
View file @
172d6289
...
...
@@ -151,10 +151,10 @@ library Lib_EthUtils {
)
{
bytes[] memory encoded = new bytes[](2);
encoded[0] = Lib_RLPWriter.
encod
eAddress(_creator);
encoded[1] = Lib_RLPWriter.
encod
eUint(_nonce);
encoded[0] = Lib_RLPWriter.
writ
eAddress(_creator);
encoded[1] = Lib_RLPWriter.
writ
eUint(_nonce);
bytes memory encodedList = Lib_RLPWriter.
encod
eList(encoded);
bytes memory encodedList = Lib_RLPWriter.
writ
eList(encoded);
return getAddressFromHash(keccak256(encodedList));
}
...
...
packages/contracts/contracts/test-libraries/rlp/TestLib_RLPWriter.sol
View file @
172d6289
...
...
@@ -10,7 +10,7 @@ import { Lib_RLPWriter } from "../../optimistic-ethereum/libraries/rlp/Lib_RLPWr
*/
contract TestLib_RLPWriter {
function
encod
eBytes(
function
writ
eBytes(
bytes memory _in
)
public
...
...
@@ -19,10 +19,10 @@ contract TestLib_RLPWriter {
bytes memory _out
)
{
return Lib_RLPWriter.
encod
eBytes(_in);
return Lib_RLPWriter.
writ
eBytes(_in);
}
function
encod
eList(
function
writ
eList(
bytes[] memory _in
)
public
...
...
@@ -31,10 +31,10 @@ contract TestLib_RLPWriter {
bytes memory _out
)
{
return Lib_RLPWriter.
encod
eList(_in);
return Lib_RLPWriter.
writ
eList(_in);
}
function
encod
eString(
function
writ
eString(
string memory _in
)
public
...
...
@@ -43,10 +43,10 @@ contract TestLib_RLPWriter {
bytes memory _out
)
{
return Lib_RLPWriter.
encod
eString(_in);
return Lib_RLPWriter.
writ
eString(_in);
}
function
encod
eAddress(
function
writ
eAddress(
address _in
)
public
...
...
@@ -55,10 +55,10 @@ contract TestLib_RLPWriter {
bytes memory _out
)
{
return Lib_RLPWriter.
encod
eAddress(_in);
return Lib_RLPWriter.
writ
eAddress(_in);
}
function
encod
eUint(
function
writ
eUint(
uint _in
)
public
...
...
@@ -67,10 +67,10 @@ contract TestLib_RLPWriter {
bytes memory _out
)
{
return Lib_RLPWriter.
encod
eUint(_in);
return Lib_RLPWriter.
writ
eUint(_in);
}
function
encod
eInt(
function
writ
eInt(
int _in
)
public
...
...
@@ -79,10 +79,10 @@ contract TestLib_RLPWriter {
bytes memory _out
)
{
return Lib_RLPWriter.
encod
eInt(_in);
return Lib_RLPWriter.
writ
eInt(_in);
}
function
encod
eBool(
function
writ
eBool(
bool _in
)
public
...
...
@@ -91,6 +91,6 @@ contract TestLib_RLPWriter {
bytes memory _out
)
{
return Lib_RLPWriter.
encod
eBool(_in);
return Lib_RLPWriter.
writ
eBool(_in);
}
}
packages/contracts/package.json
View file @
172d6289
...
...
@@ -10,7 +10,7 @@
"build:dump"
:
"ts-node
\"
bin/take-dump.ts
\"
"
,
"build:copy"
:
"copyfiles -u 2
\"
contracts/optimistic-ethereum/**/*.sol
\"
\"
build/contracts
\"
"
,
"test"
:
"yarn run test:contracts"
,
"test:contracts"
:
"buidler test
\"
test/contracts/libraries/rlp/Lib_RLPReader.spec.ts
\"
--show-stack-traces"
,
"test:contracts"
:
"buidler test --show-stack-traces"
,
"lint"
:
"yarn run lint:typescript"
,
"lint:typescript"
:
"tslint --format stylish --project ."
,
"lint:fix"
:
"yarn run lint:fix:typescript"
,
...
...
packages/contracts/test/contracts/OVM/execution/OVM_StateManager.spec.ts
View file @
172d6289
...
...
@@ -10,8 +10,8 @@ import { DUMMY_ACCOUNTS, DUMMY_BYTES32, ZERO_ADDRESS } from '../../../helpers'
const
EMPTY_ACCOUNT_CODE_HASH
=
'
0x00004B1DC0DE000000004B1DC0DE000000004B1DC0DE000000004B1DC0DE0000
'
const
RLP_NULL_HASH
=
'
0x
56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421
'
const
KECCAK_256_NULL
=
'
0x
c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
'
describe
(
'
OVM_StateManager
'
,
()
=>
{
let
signer1
:
Signer
...
...
@@ -321,7 +321,7 @@ describe('OVM_StateManager', () => {
)
).
to
.
deep
.
include
({
nonce
:
BigNumber
.
from
(
1
),
codeHash
:
RLP_NULL_HASH
,
codeHash
:
KECCAK_256_NULL
,
isFresh
:
true
,
})
})
...
...
packages/contracts/test/contracts/OVM/verification/OVM_StateTransitioner.spec.ts
View file @
172d6289
...
...
@@ -18,7 +18,7 @@ import {
import
{
MockContract
,
smockit
}
from
'
@eth-optimism/smock
'
import
{
keccak256
}
from
'
ethers/lib/utils
'
describe
(
'
OVM_StateTransitioner
'
,
()
=>
{
describe
.
skip
(
'
OVM_StateTransitioner
'
,
()
=>
{
let
AddressManager
:
Contract
before
(
async
()
=>
{
AddressManager
=
await
makeAddressManager
()
...
...
@@ -75,34 +75,39 @@ describe('OVM_StateTransitioner', () => {
})
describe
(
'
proveContractState
'
,
()
=>
{
let
ovmContractAddress
=
NON_ZERO_ADDRESS
let
ethContractAddress
=
ZERO_ADDRESS
let
account
:
any
beforeEach
(()
=>
{
Mock__OVM_StateManager
.
smocked
.
hasAccount
.
will
.
return
.
with
(
false
)
account
=
{
nonce
:
0
,
balance
:
0
,
storageRoot
:
NULL_BYTES32
,
codeHash
:
NULL_BYTES32
,
ethAddress
:
ZERO_ADDRESS
,
isFresh
:
false
,
}
})
describe
(
'
when provided an invalid code hash
'
,
()
=>
{
beforeEach
(()
=>
{
account
.
ethAddress
=
NON_ZERO_ADDRESS
account
.
codeHash
=
NON_NULL_BYTES32
})
it
(
'
should revert
'
,
async
()
=>
{
await
expect
(
OVM_StateTransitioner
.
proveContractState
(
ZERO_ADDRESS
,
account
,
'
0x
'
)
OVM_StateTransitioner
.
proveContractState
(
ovmContractAddress
,
ethContractAddress
,
account
,
'
0x
'
)
).
to
.
be
.
revertedWith
(
'
Invalid code hash provided.
'
)
})
})
describe
(
'
when provided a valid code hash
'
,
()
=>
{
beforeEach
(
async
()
=>
{
account
.
eth
Address
=
OVM_StateTransitioner
.
address
ethContract
Address
=
OVM_StateTransitioner
.
address
account
.
codeHash
=
keccak256
(
await
ethers
.
provider
.
getCode
(
OVM_StateTransitioner
.
address
)
)
...
...
@@ -114,7 +119,8 @@ describe('OVM_StateTransitioner', () => {
it
(
'
should revert
'
,
async
()
=>
{
await
expect
(
OVM_StateTransitioner
.
proveContractState
(
ZERO_ADDRESS
,
ovmContractAddress
,
ethContractAddress
,
account
,
proof
)
...
...
@@ -129,13 +135,13 @@ describe('OVM_StateTransitioner', () => {
accounts
:
[
{
...
account
,
address
:
NON_ZERO_ADDRESS
,
address
:
ovmContractAddress
,
},
],
secure
:
true
,
})
const
test
=
await
generator
.
makeAccountProofTest
(
NON_ZERO_ADDRESS
)
const
test
=
await
generator
.
makeAccountProofTest
(
ovmContractAddress
)
proof
=
test
.
accountTrieWitness
...
...
@@ -150,7 +156,8 @@ describe('OVM_StateTransitioner', () => {
it
(
'
should put the account in the state manager
'
,
async
()
=>
{
await
expect
(
OVM_StateTransitioner
.
proveContractState
(
NON_ZERO_ADDRESS
,
ovmContractAddress
,
ethContractAddress
,
account
,
proof
)
...
...
@@ -175,6 +182,10 @@ describe('OVM_StateTransitioner', () => {
})
describe
(
'
proveStorageSlot
'
,
()
=>
{
beforeEach
(()
=>
{
Mock__OVM_StateManager
.
smocked
.
hasContractStorage
.
will
.
return
.
with
(
false
)
})
describe
(
'
when the corresponding account is not proven
'
,
()
=>
{
beforeEach
(()
=>
{
Mock__OVM_StateManager
.
smocked
.
hasAccount
.
will
.
return
.
with
(
false
)
...
...
@@ -186,7 +197,6 @@ describe('OVM_StateTransitioner', () => {
NON_ZERO_ADDRESS
,
NON_NULL_BYTES32
,
NON_NULL_BYTES32
,
'
0x
'
,
'
0x
'
)
).
to
.
be
.
revertedWith
(
...
...
@@ -209,8 +219,6 @@ describe('OVM_StateTransitioner', () => {
balance
:
0
,
storageRoot
:
NULL_BYTES32
,
codeHash
:
NULL_BYTES32
,
ethAddress
:
ZERO_ADDRESS
,
isFresh
:
false
,
}
const
generator
=
await
TrieTestGenerator
.
fromAccounts
({
...
...
packages/contracts/test/contracts/libraries/rlp/Lib_RLPWriter.spec.ts
View file @
172d6289
...
...
@@ -16,13 +16,13 @@ const encode = async (Lib_RLPWriter: Contract, input: any): Promise<void> => {
})
)
return
Lib_RLPWriter
.
encod
eList
(
elements
)
return
Lib_RLPWriter
.
writ
eList
(
elements
)
}
else
if
(
Number
.
isInteger
(
input
))
{
return
Lib_RLPWriter
.
encod
eUint
(
input
)
return
Lib_RLPWriter
.
writ
eUint
(
input
)
}
else
if
(
input
[
0
]
===
'
#
'
)
{
return
Lib_RLPWriter
.
encod
eInt
(
input
.
slice
(
1
))
return
Lib_RLPWriter
.
writ
eInt
(
input
.
slice
(
1
))
}
else
{
return
Lib_RLPWriter
.
encod
eString
(
input
)
return
Lib_RLPWriter
.
writ
eString
(
input
)
}
}
...
...
packages/contracts/test/contracts/libraries/trie/Lib_EthMerkleTrie.spec.ts
deleted
100644 → 0
View file @
eabb5dd8
import
{
expect
}
from
'
../../../setup
'
/* External Imports */
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
Contract
}
from
'
ethers
'
/* Internal Imports */
import
{
TrieTestGenerator
,
NON_NULL_BYTES32
}
from
'
../../../helpers
'
import
{
keccak256
}
from
'
ethers/lib/utils
'
const
makeDummyAccounts
=
(
count
:
number
):
any
[]
=>
{
return
[...
Array
(
count
)].
map
((
x
,
idx
)
=>
{
return
{
address
:
'
0xc0de
'
+
`
${
idx
.
toString
(
16
)}
`
.
padStart
(
36
,
'
0
'
),
nonce
:
0
,
balance
:
0
,
codeHash
:
null
,
storage
:
[
{
key
:
keccak256
(
'
0x1234
'
),
val
:
keccak256
(
'
0x5678
'
),
},
],
}
})
}
const
NODE_COUNTS
=
[
1
,
2
,
128
,
256
,
512
,
1024
,
2048
,
4096
]
describe
(
'
Lib_EthMerkleTrie
'
,
()
=>
{
let
Lib_EthMerkleTrie
:
Contract
before
(
async
()
=>
{
Lib_EthMerkleTrie
=
await
(
await
ethers
.
getContractFactory
(
'
TestLib_EthMerkleTrie
'
)
).
deploy
()
})
describe
(
'
proveAccountStorageSlotValue
'
,
()
=>
{})
describe
(
'
updateAccountStorageSlotValue
'
,
()
=>
{})
describe
(
'
proveAccountState
'
,
()
=>
{
for
(
const
nodeCount
of
NODE_COUNTS
)
{
describe
(
`inside a trie with
${
nodeCount
}
nodes`
,
()
=>
{
let
generator
:
TrieTestGenerator
before
(
async
()
=>
{
generator
=
await
TrieTestGenerator
.
fromAccounts
({
accounts
:
makeDummyAccounts
(
nodeCount
),
secure
:
true
,
})
})
for
(
let
i
=
0
;
i
<
nodeCount
;
i
+=
nodeCount
/
(
nodeCount
>
8
?
8
:
1
)
)
{
it
(
`should correctly prove inclusion for node #
${
i
}
`
,
async
()
=>
{
const
test
=
await
generator
.
makeAccountProofTest
(
i
)
expect
(
await
Lib_EthMerkleTrie
.
proveAccountState
(
test
.
address
,
test
.
account
,
test
.
accountTrieWitness
,
test
.
accountTrieRoot
)
).
to
.
equal
(
true
)
})
}
})
}
})
describe
.
only
(
'
updateAccountState
'
,
()
=>
{
for
(
const
nodeCount
of
NODE_COUNTS
)
{
describe
(
`inside a trie with
${
nodeCount
}
nodes`
,
()
=>
{
let
generator
:
TrieTestGenerator
before
(
async
()
=>
{
generator
=
await
TrieTestGenerator
.
fromAccounts
({
accounts
:
makeDummyAccounts
(
nodeCount
),
secure
:
true
,
})
})
for
(
let
i
=
0
;
i
<
nodeCount
;
i
+=
nodeCount
/
(
nodeCount
>
8
?
8
:
1
)
)
{
it
(
`should correctly update node #
${
i
}
`
,
async
()
=>
{
const
test
=
await
generator
.
makeAccountUpdateTest
(
i
,
{
nonce
:
1234
,
balance
:
5678
,
codeHash
:
NON_NULL_BYTES32
,
storageRoot
:
NON_NULL_BYTES32
,
})
expect
(
await
Lib_EthMerkleTrie
.
updateAccountState
(
test
.
address
,
test
.
account
,
test
.
accountTrieWitness
,
test
.
accountTrieRoot
)
).
to
.
equal
(
test
.
newAccountTrieRoot
)
})
}
})
}
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment