11import { anyValue } from "@nomicfoundation/hardhat-chai-matchers/withArgs" ;
22import { expect } from "chai" ;
33import { deployments , ethers , getNamedAccounts , network } from "hardhat" ;
4- import { toBigInt , BytesLike } from "ethers" ;
4+ import { toBigInt } from "ethers" ;
55import {
66 PNK ,
77 KlerosCore ,
@@ -105,6 +105,7 @@ describe("Integration tests", async () => {
105105 const tx = await arbitrable [ "createDispute(string)" ] ( "future of france" , {
106106 value : arbitrationCost ,
107107 } ) ;
108+
108109 const trace = await network . provider . send ( "debug_traceTransaction" , [ tx . hash ] ) ;
109110 const [ disputeId ] = abiCoder . decode ( [ "uint" ] , `0x${ trace . returnValue } ` ) ; // get returned value from createDispute()
110111 console . log ( "Dispute Created with disputeId: %d" , disputeId ) ;
@@ -120,20 +121,23 @@ describe("Integration tests", async () => {
120121 0 ,
121122 ""
122123 ) ;
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" ) ;
125127 const disputeHash = ethers . solidityPackedKeccak256 (
126128 [ "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" ]
128130 ) ;
129131 console . log ( "dispute hash: " , disputeHash ) ;
130-
132+ if ( lastBlock . hash === null ) {
133+ process . exit ( ) ;
134+ }
131135 // Relayer tx
132136 const tx2 = await homeGateway
133137 . connect ( relayer )
134138 [ "relayCreateDispute((bytes32,uint256,address,uint256,uint256,uint256,string,uint256,bytes))" ] (
135139 {
136- foreignBlockHash : lastBlock ? .hash as BytesLike ,
140+ foreignBlockHash : ethers . toBeHex ( lastBlock . hash ) ,
137141 foreignChainID : 31337 ,
138142 foreignArbitrable : arbitrable . target ,
139143 foreignDisputeID : disputeId ,
@@ -202,5 +206,5 @@ describe("Integration tests", async () => {
202206} ) ;
203207
204208const 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 ) ) ;
206210} ;
0 commit comments