Skip to content

Commit 5a6252e

Browse files
Check sponsor saved to deal
1 parent f9a978d commit 5a6252e

File tree

2 files changed

+51
-43
lines changed

2 files changed

+51
-43
lines changed

src/Modules/IexecPoco.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
import {
2323
AccurateContribution,
2424
FaultyContribution,
25+
OrdersMatched,
2526
SchedulerNotice,
2627
TaskClaimed,
2728
TaskConsensus,
@@ -127,13 +128,10 @@ export function handleOrdersMatched(event: OrdersMatchedEvent): void {
127128
let contract = IexecInterfaceTokenContract.bind(event.address);
128129
let viewedDeal = contract.viewDeal(event.params.dealid);
129130

130-
/*
131131
fetchAccount(viewedDeal.requester.toHex()).save();
132132
fetchAccount(viewedDeal.beneficiary.toHex()).save();
133133
fetchAccount(viewedDeal.callback.toHex()).save();
134-
*/
135134
let deal = fetchDeal(event.params.dealid.toHex());
136-
/*
137135
deal.app = viewedDeal.app.pointer.toHex();
138136
deal.appOwner = viewedDeal.app.owner.toHex();
139137
deal.appPrice = toRLC(viewedDeal.app.price);
@@ -162,9 +160,7 @@ export function handleOrdersMatched(event: OrdersMatchedEvent): void {
162160
deal.requestorder = event.params.requestHash.toHex();
163161
deal.timestamp = event.block.timestamp;
164162
deal.save();
165-
*/
166163

167-
/*
168164
const dataset = deal.dataset;
169165

170166
let apporder = fetchApporder(event.params.appHash.toHex());
@@ -196,7 +192,6 @@ export function handleOrdersMatched(event: OrdersMatchedEvent): void {
196192
protocol.dealsCount = protocol.dealsCount.plus(BigInt.fromI32(1));
197193
protocol.tasksCount = protocol.tasksCount.plus(deal.botSize);
198194
protocol.save();
199-
*/
200195
}
201196

202197
export function handleSchedulerNotice(event: SchedulerNoticeEvent): void {

test/Modules/IexecPoco.test.ts

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { Address, BigInt, Bytes, ethereum } from '@graphprotocol/graph-ts';
55
import {
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

Comments
 (0)