33
44import { Address , BigInt , Bytes , ethereum } from '@graphprotocol/graph-ts' ;
55import {
6+ assert ,
67 createMockedFunction ,
78 describe ,
89 newTypedMockEventWithParams ,
@@ -17,6 +18,10 @@ describe('IexecPoco', () => {
1718 const dealId = Bytes . fromHexString (
1819 '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef' ,
1920 ) ;
21+ const appHash = dealId ;
22+ const datasetHash = dealId ;
23+ const workerpoolHash = dealId ;
24+ const requestHash = dealId ;
2025 const sponsor = Address . fromString ( '0xabcdef1234567890abcdef1234567890abcdef12' ) ;
2126 const timestamp = BigInt . fromI32 ( 123456789 ) ;
2227 const assetAddress = Address . fromString ( '0x90cBa2Bbb19ecc291A12066Fd8329D65FA1f1947' ) ;
@@ -34,56 +39,65 @@ describe('IexecPoco', () => {
3439 . withArgs ( [ ethereum . Value . fromFixedBytes ( dealId ) ] )
3540 . returns ( [
3641 ethereum . Value . fromTuple (
37- // app
3842 changetype < ethereum . Tuple > ( [
39- ethereum . Value . fromAddress ( assetAddress ) ,
40- ethereum . Value . fromAddress ( assetOwner ) ,
41- ethereum . Value . fromI32 ( assetPrice ) ,
43+ ethereum . Value . fromTuple (
44+ // app
45+ changetype < ethereum . Tuple > ( [
46+ ethereum . Value . fromAddress ( assetAddress ) ,
47+ ethereum . Value . fromAddress ( assetOwner ) ,
48+ ethereum . Value . fromI32 ( assetPrice ) ,
49+ ] ) ,
50+ ) ,
51+ ethereum . Value . fromTuple (
52+ // dataset
53+ changetype < ethereum . Tuple > ( [
54+ ethereum . Value . fromAddress ( assetAddress ) ,
55+ ethereum . Value . fromAddress ( assetOwner ) ,
56+ ethereum . Value . fromI32 ( assetPrice ) ,
57+ ] ) ,
58+ ) ,
59+ ethereum . Value . fromTuple (
60+ // workerpool
61+ changetype < ethereum . Tuple > ( [
62+ ethereum . Value . fromAddress ( assetAddress ) ,
63+ ethereum . Value . fromAddress ( assetOwner ) ,
64+ ethereum . Value . fromI32 ( assetPrice ) ,
65+ ] ) ,
66+ ) ,
67+ ethereum . Value . fromI32 ( uint256 ) , // trust
68+ ethereum . Value . fromI32 ( uint256 ) , // category
69+ ethereum . Value . fromFixedBytes ( bytes32 ) , // tag
70+ ethereum . Value . fromAddress ( address ) , // requester
71+ ethereum . Value . fromAddress ( address ) , // beneficiary
72+ ethereum . Value . fromAddress ( address ) , // callback
73+ ethereum . Value . fromString ( string ) , // params
74+ ethereum . Value . fromI32 ( uint256 ) , // startTime
75+ ethereum . Value . fromI32 ( uint256 ) , // botFirst
76+ ethereum . Value . fromI32 ( uint256 ) , // botSize
77+ ethereum . Value . fromI32 ( uint256 ) , // workerStake
78+ ethereum . Value . fromI32 ( uint256 ) , // schedulerRewardRatio
79+ ethereum . Value . fromAddress ( sponsor ) , // sponsor
4280 ] ) ,
4381 ) ,
44- ethereum . Value . fromTuple (
45- // dataset
46- changetype < ethereum . Tuple > ( [
47- ethereum . Value . fromAddress ( assetAddress ) ,
48- ethereum . Value . fromAddress ( assetOwner ) ,
49- ethereum . Value . fromI32 ( assetPrice ) ,
50- ] ) ,
51- ) ,
52- ethereum . Value . fromTuple (
53- // workerpool
54- changetype < ethereum . Tuple > ( [
55- ethereum . Value . fromAddress ( assetAddress ) ,
56- ethereum . Value . fromAddress ( assetOwner ) ,
57- ethereum . Value . fromI32 ( assetPrice ) ,
58- ] ) ,
59- ) ,
60- ethereum . Value . fromI32 ( uint256 ) , // trust
61- ethereum . Value . fromI32 ( uint256 ) , // category
62- ethereum . Value . fromFixedBytes ( bytes32 ) , // tag
63- ethereum . Value . fromAddress ( address ) , // requester
64- ethereum . Value . fromAddress ( address ) , // beneficiary
65- ethereum . Value . fromAddress ( address ) , // callback
66- ethereum . Value . fromString ( string ) , // params
67- ethereum . Value . fromI32 ( uint256 ) , // startTime
68- ethereum . Value . fromI32 ( uint256 ) , // botFirst
69- ethereum . Value . fromI32 ( uint256 ) , // botSize
70- ethereum . Value . fromI32 ( uint256 ) , // workerStake
71- ethereum . Value . fromI32 ( uint256 ) , // schedulerRewardRatio
72- ethereum . Value . fromAddress ( address ) , // sponsor
7382 ] ) ;
7483
7584 // Create the mock event
7685 let mockEvent = newTypedMockEventWithParams < OrdersMatched > ( [
77- new ethereum . EventParam ( 'deal' , ethereum . Value . fromFixedBytes ( dealId ) ) ,
86+ new ethereum . EventParam ( 'dealid' , ethereum . Value . fromFixedBytes ( dealId ) ) ,
87+ new ethereum . EventParam ( 'appHash' , ethereum . Value . fromFixedBytes ( appHash ) ) ,
88+ new ethereum . EventParam ( 'datasetHash' , ethereum . Value . fromFixedBytes ( datasetHash ) ) ,
89+ new ethereum . EventParam (
90+ 'workerpoolHash' ,
91+ ethereum . Value . fromFixedBytes ( workerpoolHash ) ,
92+ ) ,
93+ new ethereum . EventParam ( 'requestHash' , ethereum . Value . fromFixedBytes ( requestHash ) ) ,
7894 ] ) ;
7995 mockEvent . block . timestamp = timestamp ;
8096 mockEvent . address = pocoProxyAddress ;
8197
8298 // Call the handler
8399 handleOrdersMatched ( mockEvent ) ;
84100
85- /*
86-
87101 // Assert that the OrdersMatched entity was created and has correct fields
88102 const entityId = mockEvent . block . number
89103 . toString ( )
@@ -98,7 +112,6 @@ describe('IexecPoco', () => {
98112 // Assert that a transaction was logged (if applicable)
99113 const transactionId = mockEvent . transaction . hash . toHex ( ) ;
100114 assert . fieldEquals ( 'Transaction' , transactionId , 'id' , transactionId ) ;
101- */
102115 } ) ;
103116} ) ;
104117
0 commit comments