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
a5001aa1
Unverified
Commit
a5001aa1
authored
Dec 29, 2021
by
Elena Gesheva
Committed by
GitHub
Dec 29, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1931 from coolhill/increase-coverage-issue
Increase branch coverage
parents
fde2c76a
1bdf50fc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
220 additions
and
2 deletions
+220
-2
.solcover.js
packages/contracts/.solcover.js
+2
-1
package.json
packages/contracts/package.json
+1
-1
L1StandardBridge.spec.ts
...acts/test/contracts/L1/messaging/L1StandardBridge.spec.ts
+24
-0
CanonicalTransactionChain.spec.ts
...est/contracts/L1/rollup/CanonicalTransactionChain.spec.ts
+20
-0
StateCommitmentChain.spec.ts
...cts/test/contracts/L1/rollup/StateCommitmentChain.spec.ts
+57
-0
Lib_RLPReader.test.json
...acts/test/data/json/libraries/rlp/Lib_RLPReader.test.json
+108
-0
Lib_BytesUtils.test.json
...s/test/data/json/libraries/utils/Lib_BytesUtils.test.json
+8
-0
No files found.
packages/contracts/.solcover.js
View file @
a5001aa1
module
.
exports
=
{
skipFiles
:
[
'
./test-helpers
'
,
'
./test-libraries
'
'
./test-libraries
'
,
'
./L2/predeploys/OVM_DeployerWhitelist.sol
'
],
mocha
:
{
grep
:
"
@skip-on-coverage
"
,
...
...
packages/contracts/package.json
View file @
a5001aa1
...
...
@@ -25,7 +25,7 @@
"autogen:artifacts"
:
"ts-node scripts/generate-artifacts.ts && ts-node scripts/generate-deployed-artifacts.ts"
,
"test"
:
"yarn test:contracts"
,
"test:contracts"
:
"hardhat test --show-stack-traces"
,
"test:coverage"
:
"NODE_OPTIONS=--max_old_space_size=8192 hardhat coverage && istanbul check-coverage --statements
88 --branches 76 --functions 84 --lines 88
"
,
"test:coverage"
:
"NODE_OPTIONS=--max_old_space_size=8192 hardhat coverage && istanbul check-coverage --statements
90 --branches 84 --functions 88 --lines 90
"
,
"test:slither"
:
"slither ."
,
"pretest:slither"
:
"rm -f @openzeppelin && rm -f @ens && rm -f hardhat && ln -s ../../node_modules/@openzeppelin @openzeppelin && ln -s ../../node_modules/@ens @ens && ln -s ../../node_modules/hardhat hardhat"
,
"posttest:slither"
:
"rm -f @openzeppelin && rm -f @ens && rm -f hardhat"
,
...
...
packages/contracts/test/contracts/L1/messaging/L1StandardBridge.spec.ts
View file @
a5001aa1
...
...
@@ -244,6 +244,30 @@ describe('L1StandardBridge', () => {
).
to
.
be
.
revertedWith
(
ERR_INVALID_X_DOMAIN_MSG_SENDER
)
})
it
(
'
should revert in nothing to withdraw
'
,
async
()
=>
{
// make sure no balance at start of test
expect
(
await
ethers
.
provider
.
getBalance
(
NON_ZERO_ADDRESS
)).
to
.
be
.
equal
(
0
)
const
withdrawalAmount
=
100
Mock__L1CrossDomainMessenger
.
smocked
.
xDomainMessageSender
.
will
.
return
.
with
(
()
=>
DUMMY_L2_BRIDGE_ADDRESS
)
await
expect
(
L1StandardBridge
.
finalizeETHWithdrawal
(
NON_ZERO_ADDRESS
,
NON_ZERO_ADDRESS
,
withdrawalAmount
,
NON_NULL_BYTES32
,
{
from
:
Mock__L1CrossDomainMessenger
.
address
,
}
)
).
to
.
be
.
revertedWith
(
'
TransferHelper::safeTransferETH: ETH transfer failed
'
)
})
it
(
'
should credit funds to the withdrawer and not use too much gas
'
,
async
()
=>
{
// make sure no balance at start of test
expect
(
await
ethers
.
provider
.
getBalance
(
NON_ZERO_ADDRESS
)).
to
.
be
.
equal
(
0
)
...
...
packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.spec.ts
View file @
a5001aa1
...
...
@@ -679,6 +679,16 @@ describe('CanonicalTransactionChain', () => {
}
)
await
res
.
wait
()
expect
(
await
CanonicalTransactionChain
.
getLastTimestamp
()).
to
.
equal
(
timestamp
)
expect
(
await
CanonicalTransactionChain
.
getLastBlockNumber
()).
to
.
equal
(
blockNumber
)
expect
(
await
CanonicalTransactionChain
.
getNumPendingQueueElements
()
).
to
.
equal
(
0
)
})
it
(
`should return
${
size
}
`
,
async
()
=>
{
...
...
@@ -686,7 +696,17 @@ describe('CanonicalTransactionChain', () => {
size
)
})
it
(
'
should return zero after queue is emptied
'
,
async
()
=>
{
expect
(
await
CanonicalTransactionChain
.
getNextQueueIndex
()).
to
.
equal
(
0
)
})
})
}
it
(
'
should return zero
'
,
async
()
=>
{
expect
(
await
CanonicalTransactionChain
.
getTotalBatches
()).
to
.
equal
(
0
)
})
})
})
packages/contracts/test/contracts/L1/rollup/StateCommitmentChain.spec.ts
View file @
a5001aa1
...
...
@@ -181,6 +181,19 @@ describe('StateCommitmentChain', () => {
})
})
})
describe
(
'
when the proposer has not previously staked at the BondManager
'
,
()
=>
{
before
(()
=>
{
Mock__BondManager
.
smocked
.
isCollateralized
.
will
.
return
.
with
(
false
)
})
it
(
'
should revert
'
,
async
()
=>
{
await
expect
(
StateCommitmentChain
.
appendStateBatch
(
batch
,
0
)
).
to
.
be
.
revertedWith
(
'
Proposer does not have enough collateral posted
'
)
})
})
})
})
...
...
@@ -194,6 +207,10 @@ describe('StateCommitmentChain', () => {
extraData
:
ethers
.
constants
.
HashZero
,
}
before
(()
=>
{
Mock__BondManager
.
smocked
.
isCollateralized
.
will
.
return
.
with
(
true
)
})
beforeEach
(
async
()
=>
{
Mock__CanonicalTransactionChain
.
smocked
.
getTotalElements
.
will
.
return
.
with
(
batch
.
length
...
...
@@ -253,6 +270,25 @@ describe('StateCommitmentChain', () => {
})
})
describe
(
'
when outside fraud proof window
'
,
()
=>
{
beforeEach
(
async
()
=>
{
const
FRAUD_PROOF_WINDOW
=
await
StateCommitmentChain
.
FRAUD_PROOF_WINDOW
()
await
increaseEthTime
(
ethers
.
provider
,
FRAUD_PROOF_WINDOW
.
toNumber
()
+
1
)
})
it
(
'
should revert
'
,
async
()
=>
{
await
expect
(
StateCommitmentChain
.
deleteStateBatch
(
batchHeader
)
).
to
.
be
.
revertedWith
(
'
State batches can only be deleted within the fraud proof window.
'
)
})
})
describe
(
'
when the provided batch header is valid
'
,
()
=>
{
it
(
'
should remove the batch and all following batches
'
,
async
()
=>
{
await
expect
(
StateCommitmentChain
.
deleteStateBatch
(
batchHeader
)).
to
...
...
@@ -263,6 +299,27 @@ describe('StateCommitmentChain', () => {
})
})
describe
(
'
insideFraudProofWindow
'
,
()
=>
{
const
batchHeader
=
{
batchIndex
:
0
,
batchRoot
:
NON_NULL_BYTES32
,
batchSize
:
1
,
prevTotalElements
:
0
,
extraData
:
ethers
.
constants
.
HashZero
,
}
it
(
'
should revert when timestamp is zero
'
,
async
()
=>
{
await
expect
(
StateCommitmentChain
.
insideFraudProofWindow
({
...
batchHeader
,
extraData
:
ethers
.
utils
.
defaultAbiCoder
.
encode
(
[
'
uint256
'
,
'
address
'
],
[
0
,
await
sequencer
.
getAddress
()]
),
})
).
to
.
be
.
revertedWith
(
'
Batch header timestamp cannot be zero
'
)
})
})
describe
(
'
getTotalElements
'
,
()
=>
{
describe
(
'
when no batch elements have been inserted
'
,
()
=>
{
it
(
'
should return zero
'
,
async
()
=>
{
...
...
packages/contracts/test/data/json/libraries/rlp/Lib_RLPReader.test.json
View file @
a5001aa1
...
...
@@ -22,6 +22,12 @@
"0x02"
],
"revert"
:
true
},
"input value > 1 length (should revert)"
:
{
"in"
:
[
"0x0101"
],
"revert"
:
"Invalid RLP boolean value."
}
},
"readAddress"
:
{
...
...
@@ -32,6 +38,26 @@
"out"
:
[
"0x1212121212121212121212121212121212121212"
]
},
"address length = 1"
:
{
"in"
:
[
"0x12"
],
"out"
:
[
"0x0000000000000000000000000000000000000000"
]
},
"invalid address length > 21 (should revert)"
:
{
"in"
:
[
"0x94121212121212121212121212121212121212121212121212"
],
"revert"
:
"Invalid RLP address length."
},
"invalid address length < 21 (should revert)"
:
{
"in"
:
[
"0x94121212121212121212121212"
],
"revert"
:
"Invalid RLP address length."
}
},
"readBytes"
:
{
...
...
@@ -58,6 +84,38 @@
"out"
:
[
"0x7f"
]
},
"should revert if input is a list item"
:
{
"in"
:
[
"0xc7c0c1c0c3c0c1c0"
],
"revert"
:
"Invalid RLP bytes value."
},
"invalid bytes value, 0xb7 < prefix < 0xbf (should revert)"
:
{
"in"
:
[
"0xb9"
],
"revert"
:
"Invalid RLP long string length."
},
"invalid bytes value, prefix > 0xf7 (should revert)"
:
{
"in"
:
[
"0xff"
],
"revert"
:
"Invalid RLP long list length."
}
},
"readBytes32"
:
{
"should revert if input is a list item"
:
{
"in"
:
[
"0xc7c0c1c0c3c0c1c0"
],
"revert"
:
"Invalid RLP bytes32 value."
},
"invalid length > 33 (should revert)"
:
{
"in"
:
[
"0x11110000000000000000000000000000000000000000000000000000000000000000"
],
"revert"
:
"Invalid RLP bytes32 length."
}
},
"readString"
:
{
...
...
@@ -310,6 +368,56 @@
"0xca846b6579348476616c34"
]
]
},
"invalid rlp: not enough bytes for string length"
:
{
"in"
:
[
"0xefdebd"
],
"revert"
:
"Invalid RLP short list."
},
"invalid rlp: expected string length to be greater than 55"
:
{
"in"
:
[
"0xefb83600"
],
"revert"
:
"Invalid RLP short list."
},
"invalid rlp: not enough bytes for string"
:
{
"in"
:
[
"0xefdebdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
],
"revert"
:
"Invalid RLP long list length."
},
"int32Overflow"
:
{
"in"
:
[
"0xbf0f000000000000021111"
],
"revert"
:
"Invalid RLP long string."
},
"int32Overflow2"
:
{
"in"
:
[
"0xff0f000000000000021111"
],
"revert"
:
"Invalid RLP long list."
},
"incorrectLengthInArray"
:
{
"in"
:
[
"0xb9002100dc2b275d0f74e8a53e6f4ec61b27f24278820be3f82ea2110e582081b0565df0"
],
"revert"
:
"Invalid RLP list value."
},
"leadingZerosInLongLengthArray1"
:
{
"in"
:
[
"0xb90040000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"
],
"revert"
:
"Invalid RLP list value."
},
"leadingZerosInLongLengthArray2"
:
{
"in"
:
[
"0xb800"
],
"revert"
:
"Invalid RLP list value."
},
"leadingZerosInLongLengthList1"
:
{
"in"
:
[
"0xfb00000040000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"
],
"revert"
:
"Provided RLP list exceeds max list length."
},
"nonOptimalLongLengthArray1"
:
{
"in"
:
[
"0xb81000112233445566778899aabbccddeeff"
],
"revert"
:
"Invalid RLP list value."
},
"nonOptimalLongLengthArray2"
:
{
"in"
:
[
"0xb801ff"
],
"revert"
:
"Invalid RLP list value."
},
"invalid list value, 0x7f < prefix < 0xb7 (should revert)"
:
{
"in"
:
[
"0x91"
],
"revert"
:
"Invalid RLP short string."
}
}
}
...
...
packages/contracts/test/data/json/libraries/utils/Lib_BytesUtils.test.json
View file @
a5001aa1
...
...
@@ -36,6 +36,14 @@
"start > input.length"
:
{
"in"
:
[
"0x12345678"
,
5
,
1
],
"revert"
:
"Read out of bounds"
},
"input.length + 31 >= input.length"
:
{
"in"
:
[
"0x12345678"
,
5
,
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
],
"revert"
:
"slice_overflow"
},
"input.start + input.length >= input.start"
:
{
"in"
:
[
"0x12345678"
,
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
1
],
"revert"
:
"slice_overflow"
}
},
"toBytes32"
:
{
...
...
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