Skip to content

Commit

Permalink
Adding failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Jul 22, 2023
1 parent ada0cde commit 4a9d062
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
18 changes: 18 additions & 0 deletions test/data/requests/4d982f4c156e9a447f53cc54cf3f4aa449379a36.json
Original file line number Diff line number Diff line change
@@ -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\"}"
}
21 changes: 20 additions & 1 deletion test/tests/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4a9d062

Please sign in to comment.