serum-js/src/instructions.test.js

34 lines
900 B
JavaScript
Raw Normal View History

2020-08-10 06:06:31 -07:00
import { encodeInstruction } from './instructions';
2020-08-08 23:01:26 -07:00
import BN from 'bn.js';
describe('instruction', () => {
it('encodes initialize market', () => {
2020-08-10 06:06:31 -07:00
const b = encodeInstruction({
2020-08-08 23:01:26 -07:00
initializeMarket: {
baseLotSize: new BN(10),
quoteLotSize: new BN(100000),
feeRateBps: 5,
vaultSignerNonce: new BN(1),
quoteDustThreshold: new BN(10),
},
});
expect(b.toString('hex')).toEqual(
'00000000000a00000000000000a086010000000000050001000000000000000a00000000000000',
);
});
it('encodes new order', () => {
2020-08-10 06:06:31 -07:00
const b = encodeInstruction({
2020-08-08 23:01:26 -07:00
newOrder: {
2020-08-10 06:06:31 -07:00
side: 'sell',
2020-08-08 23:01:26 -07:00
limitPrice: new BN(10),
maxQuantity: new BN(5),
2020-08-10 06:06:31 -07:00
orderType: 'postOnly',
2020-08-08 23:01:26 -07:00
},
});
expect(b.toString('hex')).toEqual(
2020-08-24 15:30:44 -07:00
'0001000000010000000a000000000000000500000000000000020000000000000000000000',
2020-08-08 23:01:26 -07:00
);
});
});