Skip to content

Commit

Permalink
fix rpc response zero (AcalaNetwork#241)
Browse files Browse the repository at this point in the history
* fix rpc response zero

* add test
  • Loading branch information
ermalkaleci authored and ns212 committed Apr 3, 2023
1 parent a605d8f commit 6850417
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/chopsticks/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const createServer = async (handler: Handler, port?: number) => {
send({
id: req.id,
jsonrpc: '2.0',
result: resp || null,
result: resp ?? null,
})
} catch (e) {
logger.info('Error handling request: %s %o', e, (e as Error).stack)
Expand Down
8 changes: 6 additions & 2 deletions packages/e2e/src/system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { api, dev, env, expectJson, setupApi, testingPairs } from './helper'
setupApi(env.mandala)

describe('system rpc', () => {
const { alice } = testingPairs()

it('works', async () => {
expect(await api.rpc.system.chain()).toMatch('Acala Mandala TC8')
expect(await api.rpc.system.name()).toMatch('Acala Node')
Expand All @@ -17,9 +19,11 @@ describe('system rpc', () => {
})
})

it('get correct account next index', async () => {
const { alice } = testingPairs()
it('zero is not replaced with null', async () => {
expect(await api.rpc('system_accountNextIndex', alice.address)).toBe(0)
})

it('get correct account next index', async () => {
const nonce = async (address: string) => (await api.query.system.account(address)).nonce.toNumber()

const accountNextIndex = async (address: string) => (await api.rpc.system.accountNextIndex(address)).toNumber()
Expand Down

0 comments on commit 6850417

Please sign in to comment.