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
0448eb79
Unverified
Commit
0448eb79
authored
Jan 01, 2024
by
Michael Lynch
Committed by
GitHub
Jan 01, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: replace single-use named structs with anonymous structs (#8783)
parent
32230134
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
35 deletions
+24
-35
evm_test.go
cannon/mipsevm/evm_test.go
+4
-6
ratio_compressor_test.go
op-batcher/compressor/ratio_compressor_test.go
+4
-5
shadow_compressor_test.go
op-batcher/compressor/shadow_compressor_test.go
+2
-4
canonicalize_test.go
op-bindings/ast/canonicalize_test.go
+4
-6
position_test.go
op-challenger/game/fault/types/position_test.go
+2
-4
queue_test.go
op-service/txmgr/queue_test.go
+8
-10
No files found.
cannon/mipsevm/evm_test.go
View file @
0448eb79
...
@@ -223,13 +223,12 @@ func TestEVMSingleStep(t *testing.T) {
...
@@ -223,13 +223,12 @@ func TestEVMSingleStep(t *testing.T) {
var
tracer
vm
.
EVMLogger
var
tracer
vm
.
EVMLogger
//tracer = SourceMapTracer(t, contracts, addrs)
//tracer = SourceMapTracer(t, contracts, addrs)
type
testInput
struct
{
cases
:=
[]
struct
{
name
string
name
string
pc
uint32
pc
uint32
nextPC
uint32
nextPC
uint32
insn
uint32
insn
uint32
}
}{
cases
:=
[]
testInput
{
{
"j MSB set target"
,
0
,
4
,
0x0A
_00_00_02
},
// j 0x02_00_00_02
{
"j MSB set target"
,
0
,
4
,
0x0A
_00_00_02
},
// j 0x02_00_00_02
{
"j non-zero PC region"
,
0x10000000
,
0x10000004
,
0x08
_00_00_02
},
// j 0x2
{
"j non-zero PC region"
,
0x10000000
,
0x10000004
,
0x08
_00_00_02
},
// j 0x2
{
"jal MSB set target"
,
0
,
4
,
0x0E
_00_00_02
},
// jal 0x02_00_00_02
{
"jal MSB set target"
,
0
,
4
,
0x0E
_00_00_02
},
// jal 0x02_00_00_02
...
@@ -264,12 +263,11 @@ func TestEVMFault(t *testing.T) {
...
@@ -264,12 +263,11 @@ func TestEVMFault(t *testing.T) {
env
,
evmState
:=
NewEVMEnv
(
contracts
,
addrs
)
env
,
evmState
:=
NewEVMEnv
(
contracts
,
addrs
)
env
.
Config
.
Tracer
=
tracer
env
.
Config
.
Tracer
=
tracer
type
testInput
struct
{
cases
:=
[]
struct
{
name
string
name
string
nextPC
uint32
nextPC
uint32
insn
uint32
insn
uint32
}
}{
cases
:=
[]
testInput
{
{
"illegal instruction"
,
0
,
0xFF
_FF_FF_FF
},
{
"illegal instruction"
,
0
,
0xFF
_FF_FF_FF
},
{
"branch in delay-slot"
,
8
,
0x11
_02_00_03
},
{
"branch in delay-slot"
,
8
,
0x11
_02_00_03
},
{
"jump in delay-slot"
,
8
,
0x0c
_00_00_0c
},
{
"jump in delay-slot"
,
8
,
0x0c
_00_00_0c
},
...
...
op-batcher/compressor/ratio_compressor_test.go
View file @
0448eb79
...
@@ -16,13 +16,12 @@ func TestInputThreshold(t *testing.T) {
...
@@ -16,13 +16,12 @@ func TestInputThreshold(t *testing.T) {
TargetNumFrames
int
TargetNumFrames
int
ApproxComprRatio
float64
ApproxComprRatio
float64
}
}
type
test
struct
{
input
testInput
assertion
func
(
uint64
)
}
// Construct test cases that test the boundary conditions
// Construct test cases that test the boundary conditions
tests
:=
[]
test
{
tests
:=
[]
struct
{
input
testInput
assertion
func
(
uint64
)
}{
{
{
input
:
testInput
{
input
:
testInput
{
TargetFrameSize
:
1
,
TargetFrameSize
:
1
,
...
...
op-batcher/compressor/shadow_compressor_test.go
View file @
0448eb79
...
@@ -25,16 +25,14 @@ func randomBytes(t *testing.T, length int) []byte {
...
@@ -25,16 +25,14 @@ func randomBytes(t *testing.T, length int) []byte {
}
}
func
TestShadowCompressor
(
t
*
testing
.
T
)
{
func
TestShadowCompressor
(
t
*
testing
.
T
)
{
t
ype
test
struct
{
t
ests
:=
[]
struct
{
name
string
name
string
targetFrameSize
uint64
targetFrameSize
uint64
targetNumFrames
int
targetNumFrames
int
data
[][]
byte
data
[][]
byte
errs
[]
error
errs
[]
error
fullErr
error
fullErr
error
}
}{{
tests
:=
[]
test
{{
name
:
"no data"
,
name
:
"no data"
,
targetFrameSize
:
1
,
targetFrameSize
:
1
,
targetNumFrames
:
1
,
targetNumFrames
:
1
,
...
...
op-bindings/ast/canonicalize_test.go
View file @
0448eb79
...
@@ -10,11 +10,6 @@ import (
...
@@ -10,11 +10,6 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
type
astIDTest
struct
{
In
*
solc
.
StorageLayout
`json:"in"`
Out
*
solc
.
StorageLayout
`json:"out"`
}
func
TestCanonicalize
(
t
*
testing
.
T
)
{
func
TestCanonicalize
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
name
string
name
string
...
@@ -42,7 +37,10 @@ func TestCanonicalize(t *testing.T) {
...
@@ -42,7 +37,10 @@ func TestCanonicalize(t *testing.T) {
f
,
err
:=
os
.
Open
(
path
.
Join
(
"testdata"
,
tt
.
filename
))
f
,
err
:=
os
.
Open
(
path
.
Join
(
"testdata"
,
tt
.
filename
))
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
dec
:=
json
.
NewDecoder
(
f
)
dec
:=
json
.
NewDecoder
(
f
)
var
testData
astIDTest
var
testData
struct
{
In
*
solc
.
StorageLayout
`json:"in"`
Out
*
solc
.
StorageLayout
`json:"out"`
}
require
.
NoError
(
t
,
dec
.
Decode
(
&
testData
))
require
.
NoError
(
t
,
dec
.
Decode
(
&
testData
))
require
.
NoError
(
t
,
f
.
Close
())
require
.
NoError
(
t
,
f
.
Close
())
...
...
op-challenger/game/fault/types/position_test.go
View file @
0448eb79
...
@@ -39,7 +39,7 @@ func TestBigMSB(t *testing.T) {
...
@@ -39,7 +39,7 @@ func TestBigMSB(t *testing.T) {
}
}
}
}
type
testNodeInfo
struct
{
var
treeNodes
=
[]
struct
{
GIndex
*
big
.
Int
GIndex
*
big
.
Int
Depth
int
Depth
int
MaxDepth
int
MaxDepth
int
...
@@ -47,9 +47,7 @@ type testNodeInfo struct {
...
@@ -47,9 +47,7 @@ type testNodeInfo struct {
TraceIndex
*
big
.
Int
TraceIndex
*
big
.
Int
AttackGIndex
*
big
.
Int
// 0 indicates attack is not possible from this node
AttackGIndex
*
big
.
Int
// 0 indicates attack is not possible from this node
DefendGIndex
*
big
.
Int
// 0 indicates defend is not possible from this node
DefendGIndex
*
big
.
Int
// 0 indicates defend is not possible from this node
}
}{
var
treeNodes
=
[]
testNodeInfo
{
{
GIndex
:
bi
(
1
),
Depth
:
0
,
MaxDepth
:
4
,
IndexAtDepth
:
bi
(
0
),
TraceIndex
:
bi
(
15
),
AttackGIndex
:
bi
(
2
)},
{
GIndex
:
bi
(
1
),
Depth
:
0
,
MaxDepth
:
4
,
IndexAtDepth
:
bi
(
0
),
TraceIndex
:
bi
(
15
),
AttackGIndex
:
bi
(
2
)},
{
GIndex
:
bi
(
2
),
Depth
:
1
,
MaxDepth
:
4
,
IndexAtDepth
:
bi
(
0
),
TraceIndex
:
bi
(
7
),
AttackGIndex
:
bi
(
4
),
DefendGIndex
:
bi
(
6
)},
{
GIndex
:
bi
(
2
),
Depth
:
1
,
MaxDepth
:
4
,
IndexAtDepth
:
bi
(
0
),
TraceIndex
:
bi
(
7
),
AttackGIndex
:
bi
(
4
),
DefendGIndex
:
bi
(
6
)},
...
...
op-service/txmgr/queue_test.go
View file @
0448eb79
...
@@ -38,15 +38,6 @@ type testTx struct {
...
@@ -38,15 +38,6 @@ type testTx struct {
sendErr
bool
// error to return from send for this tx
sendErr
bool
// error to return from send for this tx
}
}
type
testCase
struct
{
name
string
// name of the test
max
uint64
// max concurrency of the queue
calls
[]
queueCall
// calls to the queue
txs
[]
testTx
// txs to generate from the factory (and potentially error in send)
nonces
[]
uint64
// expected sent tx nonces after all calls are made
total
time
.
Duration
// approx. total time it should take to complete all queue calls
}
type
mockBackendWithNonce
struct
{
type
mockBackendWithNonce
struct
{
mockBackend
mockBackend
}
}
...
@@ -65,7 +56,14 @@ func (b *mockBackendWithNonce) NonceAt(ctx context.Context, account common.Addre
...
@@ -65,7 +56,14 @@ func (b *mockBackendWithNonce) NonceAt(ctx context.Context, account common.Addre
}
}
func
TestSend
(
t
*
testing
.
T
)
{
func
TestSend
(
t
*
testing
.
T
)
{
testCases
:=
[]
testCase
{
testCases
:=
[]
struct
{
name
string
// name of the test
max
uint64
// max concurrency of the queue
calls
[]
queueCall
// calls to the queue
txs
[]
testTx
// txs to generate from the factory (and potentially error in send)
nonces
[]
uint64
// expected sent tx nonces after all calls are made
total
time
.
Duration
// approx. total time it should take to complete all queue calls
}{
{
{
name
:
"success"
,
name
:
"success"
,
max
:
5
,
max
:
5
,
...
...
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