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
23fecaeb
Commit
23fecaeb
authored
Dec 21, 2021
by
coolhill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test StateCommitmentchain
- within fraud proof window - not batchheader timestamp equal zero
parent
7a7803d8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
StateCommitmentChain.spec.ts
...cts/test/contracts/L1/rollup/StateCommitmentChain.spec.ts
+57
-0
No files found.
packages/contracts/test/contracts/L1/rollup/StateCommitmentChain.spec.ts
View file @
23fecaeb
...
@@ -181,6 +181,19 @@ describe('StateCommitmentChain', () => {
...
@@ -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', () => {
...
@@ -194,6 +207,10 @@ describe('StateCommitmentChain', () => {
extraData
:
ethers
.
constants
.
HashZero
,
extraData
:
ethers
.
constants
.
HashZero
,
}
}
before
(()
=>
{
Mock__BondManager
.
smocked
.
isCollateralized
.
will
.
return
.
with
(
true
)
})
beforeEach
(
async
()
=>
{
beforeEach
(
async
()
=>
{
Mock__CanonicalTransactionChain
.
smocked
.
getTotalElements
.
will
.
return
.
with
(
Mock__CanonicalTransactionChain
.
smocked
.
getTotalElements
.
will
.
return
.
with
(
batch
.
length
batch
.
length
...
@@ -253,6 +270,25 @@ describe('StateCommitmentChain', () => {
...
@@ -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
'
,
()
=>
{
describe
(
'
when the provided batch header is valid
'
,
()
=>
{
it
(
'
should remove the batch and all following batches
'
,
async
()
=>
{
it
(
'
should remove the batch and all following batches
'
,
async
()
=>
{
await
expect
(
StateCommitmentChain
.
deleteStateBatch
(
batchHeader
)).
to
await
expect
(
StateCommitmentChain
.
deleteStateBatch
(
batchHeader
)).
to
...
@@ -263,6 +299,27 @@ describe('StateCommitmentChain', () => {
...
@@ -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
(
'
getTotalElements
'
,
()
=>
{
describe
(
'
when no batch elements have been inserted
'
,
()
=>
{
describe
(
'
when no batch elements have been inserted
'
,
()
=>
{
it
(
'
should return zero
'
,
async
()
=>
{
it
(
'
should return zero
'
,
async
()
=>
{
...
...
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