1
1
import { anyValue } from "@nomicfoundation/hardhat-chai-matchers/withArgs" ;
2
2
import { expect } from "chai" ;
3
3
import { deployments , ethers , getNamedAccounts , network } from "hardhat" ;
4
- import { toBigInt , BytesLike } from "ethers" ;
4
+ import { toBigInt } from "ethers" ;
5
5
import {
6
6
PNK ,
7
7
KlerosCore ,
@@ -105,6 +105,7 @@ describe("Integration tests", async () => {
105
105
const tx = await arbitrable [ "createDispute(string)" ] ( "future of france" , {
106
106
value : arbitrationCost ,
107
107
} ) ;
108
+
108
109
const trace = await network . provider . send ( "debug_traceTransaction" , [ tx . hash ] ) ;
109
110
const [ disputeId ] = abiCoder . decode ( [ "uint" ] , `0x${ trace . returnValue } ` ) ; // get returned value from createDispute()
110
111
console . log ( "Dispute Created with disputeId: %d" , disputeId ) ;
@@ -120,20 +121,23 @@ describe("Integration tests", async () => {
120
121
0 ,
121
122
""
122
123
) ;
123
-
124
- const lastBlock = await ethers . provider . getBlock ( tx . blockNumber ?? 0 - 1 ) ;
124
+ if ( tx . blockNumber === null ) throw new Error ( "tx.blockNumber is null" ) ;
125
+ const lastBlock = await ethers . provider . getBlock ( tx . blockNumber - 1 ) ;
126
+ if ( lastBlock === null ) throw new Error ( "lastBlock is null" ) ;
125
127
const disputeHash = ethers . solidityPackedKeccak256 (
126
128
[ "bytes" , "bytes32" , "uint256" , "address" , "uint256" , "uint256" , "bytes" ] ,
127
- [ ethers . toUtf8Bytes ( "createDispute" ) , lastBlock ? .hash , 31337 , arbitrable . target , disputeId , 2 , "0x00" ]
129
+ [ ethers . toUtf8Bytes ( "createDispute" ) , lastBlock . hash , 31337 , arbitrable . target , disputeId , 2 , "0x00" ]
128
130
) ;
129
131
console . log ( "dispute hash: " , disputeHash ) ;
130
-
132
+ if ( lastBlock . hash === null ) {
133
+ process . exit ( ) ;
134
+ }
131
135
// Relayer tx
132
136
const tx2 = await homeGateway
133
137
. connect ( relayer )
134
138
[ "relayCreateDispute((bytes32,uint256,address,uint256,uint256,uint256,string,uint256,bytes))" ] (
135
139
{
136
- foreignBlockHash : lastBlock ? .hash as BytesLike ,
140
+ foreignBlockHash : ethers . toBeHex ( lastBlock . hash ) ,
137
141
foreignChainID : 31337 ,
138
142
foreignArbitrable : arbitrable . target ,
139
143
foreignDisputeID : disputeId ,
@@ -202,5 +206,5 @@ describe("Integration tests", async () => {
202
206
} ) ;
203
207
204
208
const logJurorBalance = async ( result ) => {
205
- console . log ( "staked=%s, locked=%s" , ethers . formatUnits ( result . totalLocked ) , ethers . formatUnits ( result . totalStaked ) ) ;
209
+ console . log ( "staked=%s, locked=%s" , ethers . formatUnits ( result . totalStaked ) , ethers . formatUnits ( result . totalLocked ) ) ;
206
210
} ;
0 commit comments