diff --git a/examples/x2y2-database/src/processor.test.ts b/examples/x2y2-database/src/processor.test.ts index 3bbccb564..a7e05168b 100644 --- a/examples/x2y2-database/src/processor.test.ts +++ b/examples/x2y2-database/src/processor.test.ts @@ -1,16 +1,31 @@ import assert from 'assert' import { before, describe, test } from 'node:test' import { TestProcessorServer } from '@sentio/sdk/testing' +import { mockTransferLog } from '@sentio/sdk/eth/builtin/erc20' +import { User } from './schema/schema.js' describe('Test Processor', () => { - const service = new TestProcessorServer(async () => await import('./processor.js')) + const server = new TestProcessorServer(async () => await import('./processor.js')) before(async () => { - await service.start() + await server.start() }) test('has config', async () => { - const config = await service.getConfig({}) + const config = await server.getConfig({}) assert(config.contractConfigs.length > 0) }) + + test('data is upsert', async () => { + await server.eth.testLog( + mockTransferLog('0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9', { + from: '0x0000000000000000000000000000000000000000', + to: '0xb329e39ebefd16f40d38f07643652ce17ca5bac1', + value: 10n ** 18n * 10n + }) + ) + + const from = await server.store.list(User) + assert(from.length == 2) + }) }) diff --git a/examples/x2y2-database/src/processor.ts b/examples/x2y2-database/src/processor.ts index 83d5606a9..49cf58fa4 100644 --- a/examples/x2y2-database/src/processor.ts +++ b/examples/x2y2-database/src/processor.ts @@ -37,13 +37,13 @@ ERC20Processor.bind({ address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9' }).o // exporter.emit(ctx, event) const from = new User({ name: 'from', - id: event.args.from + id: event.args.from.toLowerCase() }) await ctx.store.upsert(from) const to = new User({ name: 'to', - id: event.args.to + id: event.args.to.toLowerCase() }) await ctx.store.upsert(to) const transfer = new Transfer({