Skip to content

Commit 3be4634

Browse files
committed
fix: properly parse the tx receipt logs in the test
1 parent e615141 commit 3be4634

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

test/internal/client.spec.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ import {
1515
Annotation,
1616
Tagged,
1717
type AccountData,
18+
golemBaseABI,
1819
} from "../../src/index.ts"
1920
import {
2021
generateRandomBytes,
2122
generateRandomString,
2223
} from "../utils.ts"
2324
import { GolemBaseClient } from '../../src/internal/client.ts'
25+
import { decodeEventLog, toHex } from 'viem'
2426

2527
const log = new Logger<ILogObj>({
2628
type: "pretty",
@@ -146,13 +148,26 @@ describe("the internal golem-base client", () => {
146148
numericAnnotations: [new Annotation("ix", 3)]
147149
}
148150
]
149-
const receipts = await client.walletClient.sendGolemBaseTransactionAndWaitForReceipt(creates)
151+
const receipt = await client.walletClient.sendGolemBaseTransactionAndWaitForReceipt(creates)
150152
entitiesOwnedCount += creates.length;
151-
// Save this key for later
152-
[{ entityKey, expirationBlock }] = receipts.logs.map(txlog => ({
153-
entityKey: txlog.topics[1] as Hex,
154-
expirationBlock: parseInt(txlog.data),
155-
}))
153+
154+
const txlog = receipt.logs[0]
155+
const parsed = decodeEventLog({
156+
abi: golemBaseABI,
157+
data: txlog.data,
158+
topics: txlog.topics
159+
})
160+
161+
expect(parsed.eventName).to.eql("GolemBaseStorageEntityCreated")
162+
163+
if (parsed.eventName === "GolemBaseStorageEntityCreated") {
164+
// Save these for later
165+
entityKey = toHex(parsed.args.entityKey, { size: 32 })
166+
expirationBlock = Number(parsed.args.expirationBlock)
167+
}
168+
169+
expect(entityKey).to.exist
170+
expect(expirationBlock).to.exist
156171

157172
expect(await numOfEntitiesOwned(client)).to.eql(entitiesOwnedCount)
158173
})

0 commit comments

Comments
 (0)