diff --git a/test/data/requests/4d982f4c156e9a447f53cc54cf3f4aa449379a36.json b/test/data/requests/4d982f4c156e9a447f53cc54cf3f4aa449379a36.json new file mode 100644 index 0000000..0ecc5b0 --- /dev/null +++ b/test/data/requests/4d982f4c156e9a447f53cc54cf3f4aa449379a36.json @@ -0,0 +1,18 @@ +{ + "request": { + "path": "https://eos.greymass.com/v1/chain/get_table_rows", + "params": { + "method": "POST", + "body": "{\"table\":\"namebids\",\"limit\":1,\"code\":\"eosio\",\"scope\":\"eosio\",\"index_position\":\"primary\",\"json\":false,\"key_type\":\"name\"}" + } + }, + "status": 200, + "json": { + "rows": [ + "0000000000000000a09863fe4d96bc66b80b000000000000a002d1d51e6f0500" + ], + "more": true, + "next_key": "594475150812905472" + }, + "text": "{\"rows\":[\"0000000000000000a09863fe4d96bc66b80b000000000000a002d1d51e6f0500\"],\"more\":true,\"next_key\":\"594475150812905472\"}" +} \ No newline at end of file diff --git a/test/tests/table.ts b/test/tests/table.ts index cffa479..78da6d6 100644 --- a/test/tests/table.ts +++ b/test/tests/table.ts @@ -2,7 +2,7 @@ import {assert} from 'chai' import ContractKit, {Contract, Table, TableCursor} from '$lib' -import {Asset, Name, Serializer} from '@greymass/eosio' +import {Asset, Int64, Name, Serializer, Struct, TimePoint} from '@greymass/eosio' import {makeClient} from '@wharfkit/mock-data' const mockClient = makeClient('https://eos.greymass.com') @@ -73,6 +73,25 @@ suite('Table', () => { const cursor = nameBidTable.cursor() assert.instanceOf(cursor, TableCursor) }) + test('rowType', async () => { + @Struct.type('name_bid') + class NameBid extends Struct { + @Struct.field(Name) newname!: Name + @Struct.field(Name) high_bidder!: Name + @Struct.field(Int64) high_bid!: Int64 + @Struct.field(TimePoint) last_bid_time!: TimePoint + } + const table = new Table({ + contract: eosio, + name: 'namebids', + rowType: NameBid, + }) + assert.instanceOf(table, Table) + const rows = await table.first(1).next() + assert.instanceOf(rows[0], NameBid) + // assert.instanceOf(rows[0].newname, Name) + console.log(JSON.stringify(rows[0].newname)) + }) suite('all', () => { test('should return every single row in a table', async () => { const tableCursor = decentiumTrendingTable.cursor()