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
eb0854e7
Commit
eb0854e7
authored
Sep 05, 2021
by
rajivpoc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended test coverage of core-utils
parent
0f133753
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
149 additions
and
2 deletions
+149
-2
nice-waves-jog.md
.changeset/nice-waves-jog.md
+5
-0
batch-encoder.spec.ts
packages/core-utils/test/coders/batch-encoder.spec.ts
+23
-0
hex-utils.spec.ts
packages/core-utils/test/common/hex-utils.spec.ts
+99
-1
misc.spec.ts
packages/core-utils/test/common/misc.spec.ts
+13
-0
fees.spec.ts
packages/core-utils/test/fees/fees.spec.ts
+9
-1
No files found.
.changeset/nice-waves-jog.md
0 → 100644
View file @
eb0854e7
---
'
@eth-optimism/core-utils'
:
patch
---
increased coverage of core-utils
packages/core-utils/test/coders/batch-encoder.spec.ts
View file @
eb0854e7
...
...
@@ -50,5 +50,28 @@ describe('BatchEncoder', () => {
expect
(
encoded
).
to
.
equal
(
calldata
)
}
})
it
(
'
should throw an error
'
,
()
=>
{
const
batch
=
{
shouldStartAtElement
:
10
,
totalElementsToAppend
:
1
,
contexts
:
[
{
numSequencedTransactions
:
2
,
numSubsequentQueueTransactions
:
1
,
timestamp
:
100
,
blockNumber
:
200
,
},
],
transactions
:
[
'
0x454234000000112
'
,
'
0x45423400000012
'
],
}
expect
(()
=>
encodeAppendSequencerBatch
(
batch
)).
to
.
throw
(
'
Unexpected uneven hex string value!
'
)
expect
(()
=>
sequencerBatch
.
decode
(
'
0x
'
)).
to
.
throw
(
'
Incorrect function signature
'
)
})
})
})
packages/core-utils/test/common/hex-utils.spec.ts
View file @
eb0854e7
...
...
@@ -2,7 +2,105 @@ import { expect } from '../setup'
import
{
BigNumber
}
from
'
ethers
'
/* Imports: Internal */
import
{
toRpcHexString
}
from
'
../../src
'
import
{
toRpcHexString
,
remove0x
,
add0x
,
fromHexString
,
toHexString
,
padHexString
,
}
from
'
../../src
'
describe
(
'
remove0x
'
,
()
=>
{
it
(
'
should return undefined
'
,
()
=>
{
expect
(
remove0x
(
undefined
)).
to
.
deep
.
equal
(
undefined
)
})
it
(
'
should return without a 0x
'
,
()
=>
{
const
cases
=
[
{
input
:
'
0x
'
,
output
:
''
},
{
input
:
'
0x1f9840a85d5af5bf1d1762f925bdaddc4201f984
'
,
output
:
'
1f9840a85d5af5bf1d1762f925bdaddc4201f984
'
,
},
{
input
:
'
a
'
,
output
:
'
a
'
},
]
for
(
const
test
of
cases
)
{
expect
(
remove0x
(
test
.
input
)).
to
.
deep
.
equal
(
test
.
output
)
}
})
})
describe
(
'
add0x
'
,
()
=>
{
it
(
'
should return undefined
'
,
()
=>
{
expect
(
add0x
(
undefined
)).
to
.
deep
.
equal
(
undefined
)
})
it
(
'
should return with a 0x
'
,
()
=>
{
const
cases
=
[
{
input
:
'
0x
'
,
output
:
'
0x
'
},
{
input
:
'
1f9840a85d5af5bf1d1762f925bdaddc4201f984
'
,
output
:
'
0x1f9840a85d5af5bf1d1762f925bdaddc4201f984
'
,
},
{
input
:
''
,
output
:
'
0x
'
},
]
for
(
const
test
of
cases
)
{
expect
(
add0x
(
test
.
input
)).
to
.
deep
.
equal
(
test
.
output
)
}
})
})
describe
(
'
toHexString
'
,
()
=>
{
it
(
'
should return undefined
'
,
()
=>
{
expect
(
add0x
(
undefined
)).
to
.
deep
.
equal
(
undefined
)
})
it
(
'
should return with a hex string
'
,
()
=>
{
const
cases
=
[
{
input
:
0
,
output
:
'
0x00
'
},
{
input
:
'
0
'
,
output
:
'
0x30
'
,
},
{
input
:
''
,
output
:
'
0x
'
},
]
for
(
const
test
of
cases
)
{
expect
(
toHexString
(
test
.
input
)).
to
.
deep
.
equal
(
test
.
output
)
}
})
})
describe
(
'
fromHexString
'
,
()
=>
{
it
(
'
should return a buffer from a hex string
'
,
()
=>
{
const
cases
=
[
{
input
:
'
0x
'
,
output
:
Buffer
.
from
(
''
,
'
hex
'
)
},
{
input
:
'
0x1f9840a85d5af5bf1d1762f925bdaddc4201f984
'
,
output
:
Buffer
.
from
(
'
1f9840a85d5af5bf1d1762f925bdaddc4201f984
'
,
'
hex
'
),
},
{
input
:
''
,
output
:
Buffer
.
from
(
''
,
'
hex
'
)
},
{
input
:
Buffer
.
from
(
'
1f9840a85d5af5bf1d1762f925bdaddc4201f984
'
),
output
:
Buffer
.
from
(
'
1f9840a85d5af5bf1d1762f925bdaddc4201f984
'
),
},
]
for
(
const
test
of
cases
)
{
expect
(
fromHexString
(
test
.
input
)).
to
.
deep
.
equal
(
test
.
output
)
}
})
})
describe
(
'
padHexString
'
,
()
=>
{
it
(
'
should return return input string if length is 2 + length * 2
'
,
()
=>
{
expect
(
padHexString
(
'
abcd
'
,
1
)).
to
.
deep
.
equal
(
'
abcd
'
)
expect
(
padHexString
(
'
abcdefgh
'
,
3
).
length
).
to
.
deep
.
equal
(
8
)
})
it
(
'
should return a string padded with 0x and zeros
'
,
()
=>
{
expect
(
padHexString
(
'
0xabcd
'
,
3
)).
to
.
deep
.
equal
(
'
0x00abcd
'
)
})
})
describe
(
'
toRpcHexString
'
,
()
=>
{
it
(
'
should parse 0
'
,
()
=>
{
...
...
packages/core-utils/test/common/misc.spec.ts
0 → 100644
View file @
eb0854e7
import
{
expect
}
from
'
../setup
'
/* Imports: Internal */
import
{
sleep
}
from
'
../../src
'
describe
(
'
sleep
'
,
async
()
=>
{
it
(
'
should return wait input amount of ms
'
,
async
()
=>
{
const
startTime
=
Date
.
now
()
await
sleep
(
1000
)
const
endTime
=
Date
.
now
()
expect
(
startTime
+
1000
<=
endTime
).
to
.
deep
.
equal
(
true
)
})
})
packages/core-utils/test/fees/fees.spec.ts
View file @
eb0854e7
import
{
expect
}
from
'
../setup
'
import
*
as
fees
from
'
../../src/fees
'
import
{
utils
}
from
'
ethers
'
import
{
BigNumber
,
utils
}
from
'
ethers
'
const
hundredBillion
=
10
**
11
const
tenThousand
=
10
**
4
describe
(
'
Fees
'
,
()
=>
{
it
(
'
should count zeros and ones
'
,
()
=>
{
...
...
@@ -116,5 +117,12 @@ describe('Fees', () => {
expect
(
decoded
).
to
.
deep
.
eq
(
roundedL2GasLimit
)
})
}
it
(
'
should decode numbers
'
,
()
=>
{
const
x
=
1
expect
(
fees
.
TxGasLimit
.
decode
(
x
)).
to
.
deep
.
equal
(
BigNumber
.
from
(
x
*
tenThousand
)
)
})
})
})
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