Skip to content

Commit 620a0d6

Browse files
committed
add test for renamed event field
1 parent b533f6d commit 620a0d6

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

packages/cli/src/scaffold/ethereum.test.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const TEST_EVENT = {
2626
],
2727
},
2828
{ name: 'd', type: 'string', indexed: true },
29+
{ name: 'id', type: 'string' },
2930
],
3031
};
3132

@@ -106,7 +107,7 @@ dataSources:
106107
- name: Contract
107108
file: ./abis/Contract.json
108109
eventHandlers:
109-
- event: ExampleEvent(indexed uint256,bytes[4],string,(uint256,bytes32,string,(uint96,string,bytes32)),indexed string)
110+
- event: ExampleEvent(indexed uint256,bytes[4],string,(uint256,bytes32,string,(uint96,string,bytes32)),indexed string,string)
110111
handler: handleExampleEvent
111112
- event: ExampleEvent(bytes32)
112113
handler: handleExampleEvent1
@@ -139,6 +140,7 @@ type ExampleEvent @entity(immutable: true) {
139140
c_c3_value1: String! # string
140141
c_c3_value2: Bytes! # bytes32
141142
d: String! # string
143+
internal_id: String! # string
142144
blockNumber: BigInt!
143145
blockTimestamp: BigInt!
144146
transactionHash: Bytes!
@@ -233,6 +235,7 @@ export function handleExampleEvent(event: ExampleEventEvent): void {
233235
entity.c_c3_value1 = event.params.c.c3.value1
234236
entity.c_c3_value2 = event.params.c.c3.value2
235237
entity.d = event.params.d
238+
entity.internal_id = event.params.id
236239
237240
entity.blockNumber = event.block.number
238241
entity.blockTimestamp = event.block.timestamp
@@ -285,7 +288,8 @@ describe("Describe entity assertions", () => {
285288
let param2 = "Example string value"
286289
let c = "ethereum.Tuple Not implemented"
287290
let d = "Example string value"
288-
let newExampleEventEvent = createExampleEventEvent(a, b, param2, c, d)
291+
let id = "Example string value"
292+
let newExampleEventEvent = createExampleEventEvent(a, b, param2, c, d, id)
289293
handleExampleEvent(newExampleEventEvent)
290294
})
291295
@@ -346,7 +350,8 @@ export function createExampleEventEvent(
346350
b: Array<Bytes>,
347351
param2: string,
348352
c: ethereum.Tuple,
349-
d: string
353+
d: string,
354+
id: string
350355
): ExampleEvent {
351356
let exampleEventEvent = changetype<ExampleEvent>(newMockEvent())
352357
@@ -367,6 +372,9 @@ export function createExampleEventEvent(
367372
exampleEventEvent.parameters.push(
368373
new ethereum.EventParam("d", ethereum.Value.fromString(d))
369374
)
375+
exampleEventEvent.parameters.push(
376+
new ethereum.EventParam("id", ethereum.Value.fromString(id))
377+
)
370378
371379
return exampleEventEvent
372380
}
@@ -415,7 +423,8 @@ describe("Describe entity assertions", () => {
415423
let param2 = "Example string value"
416424
let c = "ethereum.Tuple Not implemented"
417425
let d = "Example string value"
418-
let newExampleEventEvent = createExampleEventEvent(a, b, param2, c, d)
426+
let id = "Example string value"
427+
let newExampleEventEvent = createExampleEventEvent(a, b, param2, c, d, id)
419428
handleExampleEvent(newExampleEventEvent)
420429
})
421430
@@ -476,7 +485,8 @@ export function createExampleEventEvent(
476485
b: Array<Bytes>,
477486
param2: string,
478487
c: ethereum.Tuple,
479-
d: string
488+
d: string,
489+
id: string
480490
): ExampleEvent {
481491
let exampleEventEvent = changetype<ExampleEvent>(newMockEvent())
482492
@@ -497,6 +507,9 @@ export function createExampleEventEvent(
497507
exampleEventEvent.parameters.push(
498508
new ethereum.EventParam("d", ethereum.Value.fromString(d))
499509
)
510+
exampleEventEvent.parameters.push(
511+
new ethereum.EventParam("id", ethereum.Value.fromString(id))
512+
)
500513
501514
return exampleEventEvent
502515
}

0 commit comments

Comments
 (0)