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
50bfcebc
Commit
50bfcebc
authored
Nov 04, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get challenge id
parent
bc1822e7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
Challenge.sol
contracts/Challenge.sol
+2
-0
challenge_test.js
test/challenge_test.js
+5
-2
No files found.
contracts/Challenge.sol
View file @
50bfcebc
...
...
@@ -55,6 +55,7 @@ contract Challenge {
// create challenge
uint256 public lastChallengeId = 0;
event ChallengeCreate(uint256 challengeId);
function newChallengeTrusted(bytes32 startState, bytes32 finalSystemState, uint256 stepCount) internal returns (uint256) {
uint256 challengeId = lastChallengeId;
Chal storage c = challenges[challengeId];
...
...
@@ -73,6 +74,7 @@ contract Challenge {
c.R = stepCount;
// find me later
emit ChallengeCreate(challengeId);
return challengeId;
}
...
...
test/challenge_test.js
View file @
50bfcebc
...
...
@@ -30,7 +30,7 @@ describe("Challenge contract", function () {
let
preimages
=
Object
.
assign
({},
startTrie
[
'
preimages
'
],
finalTrie
[
'
preimages
'
]);
const
finalSystemState
=
finalTrie
[
'
root
'
]
let
args
=
[
blockNumberN
,
blockNp1Rlp
,
assertionRoot
,
finalSystemState
,
1
]
let
args
=
[
blockNumberN
,
blockNp1Rlp
,
assertionRoot
,
finalSystemState
,
finalTrie
[
'
step
'
]
]
let
cdat
=
c
.
interface
.
encodeFunctionData
(
"
InitiateChallenge
"
,
args
)
let
nodes
=
await
getTrieNodesForCall
(
c
,
cdat
,
preimages
)
...
...
@@ -39,6 +39,9 @@ describe("Challenge contract", function () {
await
mm
.
AddTrieNode
(
n
)
}
let
ret
=
await
c
.
InitiateChallenge
(...
args
)
console
.
log
(
await
ret
.
wait
())
let
receipt
=
await
ret
.
wait
()
// ChallengeCreate event
let
challengeId
=
receipt
.
events
[
0
].
args
[
'
challengeId
'
].
toNumber
()
console
.
log
(
"
new challenge with id
"
,
challengeId
)
}).
timeout
(
60000
)
})
\ No newline at end of file
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