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
85838ca6
Unverified
Commit
85838ca6
authored
Jul 17, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Add tests for Position attack and defend.
parent
f5495cfe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
15 deletions
+39
-15
position_test.go
op-challenger/fault/position_test.go
+39
-15
No files found.
op-challenger/fault/position_test.go
View file @
85838ca6
...
@@ -36,27 +36,29 @@ type testNodeInfo struct {
...
@@ -36,27 +36,29 @@ type testNodeInfo struct {
Depth
int
Depth
int
IndexAtDepth
int
IndexAtDepth
int
TraceIndex
uint64
TraceIndex
uint64
AttackGIndex
uint64
// 0 indicates attack is not possible from this node
DefendGIndex
uint64
// 0 indicates defend is not possible from this node
}
}
var
treeNodesMaxDepth4
=
[]
testNodeInfo
{
var
treeNodesMaxDepth4
=
[]
testNodeInfo
{
{
GIndex
:
1
,
Depth
:
0
,
IndexAtDepth
:
0
,
TraceIndex
:
15
},
{
GIndex
:
1
,
Depth
:
0
,
IndexAtDepth
:
0
,
TraceIndex
:
15
,
AttackGIndex
:
2
},
{
GIndex
:
2
,
Depth
:
1
,
IndexAtDepth
:
0
,
TraceIndex
:
7
},
{
GIndex
:
2
,
Depth
:
1
,
IndexAtDepth
:
0
,
TraceIndex
:
7
,
AttackGIndex
:
4
,
DefendGIndex
:
6
},
{
GIndex
:
3
,
Depth
:
1
,
IndexAtDepth
:
1
,
TraceIndex
:
15
},
{
GIndex
:
3
,
Depth
:
1
,
IndexAtDepth
:
1
,
TraceIndex
:
15
,
AttackGIndex
:
6
},
{
GIndex
:
4
,
Depth
:
2
,
IndexAtDepth
:
0
,
TraceIndex
:
3
},
{
GIndex
:
4
,
Depth
:
2
,
IndexAtDepth
:
0
,
TraceIndex
:
3
,
AttackGIndex
:
8
,
DefendGIndex
:
10
},
{
GIndex
:
5
,
Depth
:
2
,
IndexAtDepth
:
1
,
TraceIndex
:
7
},
{
GIndex
:
5
,
Depth
:
2
,
IndexAtDepth
:
1
,
TraceIndex
:
7
,
AttackGIndex
:
10
},
{
GIndex
:
6
,
Depth
:
2
,
IndexAtDepth
:
2
,
TraceIndex
:
11
},
{
GIndex
:
6
,
Depth
:
2
,
IndexAtDepth
:
2
,
TraceIndex
:
11
,
AttackGIndex
:
12
,
DefendGIndex
:
14
},
{
GIndex
:
7
,
Depth
:
2
,
IndexAtDepth
:
3
,
TraceIndex
:
15
},
{
GIndex
:
7
,
Depth
:
2
,
IndexAtDepth
:
3
,
TraceIndex
:
15
,
AttackGIndex
:
14
},
{
GIndex
:
8
,
Depth
:
3
,
IndexAtDepth
:
0
,
TraceIndex
:
1
},
{
GIndex
:
8
,
Depth
:
3
,
IndexAtDepth
:
0
,
TraceIndex
:
1
,
AttackGIndex
:
16
,
DefendGIndex
:
18
},
{
GIndex
:
9
,
Depth
:
3
,
IndexAtDepth
:
1
,
TraceIndex
:
3
},
{
GIndex
:
9
,
Depth
:
3
,
IndexAtDepth
:
1
,
TraceIndex
:
3
,
AttackGIndex
:
18
},
{
GIndex
:
10
,
Depth
:
3
,
IndexAtDepth
:
2
,
TraceIndex
:
5
},
{
GIndex
:
10
,
Depth
:
3
,
IndexAtDepth
:
2
,
TraceIndex
:
5
,
AttackGIndex
:
20
,
DefendGIndex
:
22
},
{
GIndex
:
11
,
Depth
:
3
,
IndexAtDepth
:
3
,
TraceIndex
:
7
},
{
GIndex
:
11
,
Depth
:
3
,
IndexAtDepth
:
3
,
TraceIndex
:
7
,
AttackGIndex
:
22
},
{
GIndex
:
12
,
Depth
:
3
,
IndexAtDepth
:
4
,
TraceIndex
:
9
},
{
GIndex
:
12
,
Depth
:
3
,
IndexAtDepth
:
4
,
TraceIndex
:
9
,
AttackGIndex
:
24
,
DefendGIndex
:
26
},
{
GIndex
:
13
,
Depth
:
3
,
IndexAtDepth
:
5
,
TraceIndex
:
11
},
{
GIndex
:
13
,
Depth
:
3
,
IndexAtDepth
:
5
,
TraceIndex
:
11
,
AttackGIndex
:
26
},
{
GIndex
:
14
,
Depth
:
3
,
IndexAtDepth
:
6
,
TraceIndex
:
13
},
{
GIndex
:
14
,
Depth
:
3
,
IndexAtDepth
:
6
,
TraceIndex
:
13
,
AttackGIndex
:
28
,
DefendGIndex
:
30
},
{
GIndex
:
15
,
Depth
:
3
,
IndexAtDepth
:
7
,
TraceIndex
:
15
},
{
GIndex
:
15
,
Depth
:
3
,
IndexAtDepth
:
7
,
TraceIndex
:
15
,
AttackGIndex
:
30
},
{
GIndex
:
16
,
Depth
:
4
,
IndexAtDepth
:
0
,
TraceIndex
:
0
},
{
GIndex
:
16
,
Depth
:
4
,
IndexAtDepth
:
0
,
TraceIndex
:
0
},
{
GIndex
:
17
,
Depth
:
4
,
IndexAtDepth
:
1
,
TraceIndex
:
1
},
{
GIndex
:
17
,
Depth
:
4
,
IndexAtDepth
:
1
,
TraceIndex
:
1
},
...
@@ -95,3 +97,25 @@ func TestTraceIndex(t *testing.T) {
...
@@ -95,3 +97,25 @@ func TestTraceIndex(t *testing.T) {
require
.
Equal
(
t
,
test
.
TraceIndex
,
result
)
require
.
Equal
(
t
,
test
.
TraceIndex
,
result
)
}
}
}
}
func
TestAttack
(
t
*
testing
.
T
)
{
for
_
,
test
:=
range
treeNodesMaxDepth4
{
if
test
.
AttackGIndex
==
0
{
continue
}
pos
:=
NewPosition
(
test
.
Depth
,
test
.
IndexAtDepth
)
result
:=
pos
.
Attack
()
require
.
Equalf
(
t
,
test
.
AttackGIndex
,
result
.
ToGIndex
(),
"Attack from GIndex %v"
,
pos
.
ToGIndex
())
}
}
func
TestDefend
(
t
*
testing
.
T
)
{
for
_
,
test
:=
range
treeNodesMaxDepth4
{
if
test
.
DefendGIndex
==
0
{
continue
}
pos
:=
NewPosition
(
test
.
Depth
,
test
.
IndexAtDepth
)
result
:=
pos
.
Defend
()
require
.
Equalf
(
t
,
test
.
DefendGIndex
,
result
.
ToGIndex
(),
"Defend from GIndex %v"
,
pos
.
ToGIndex
())
}
}
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