Skip to content

Commit

Permalink
fix(tx-builder): field DelegateIds in ChannelCreateTx
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Dec 29, 2022
1 parent 46658bb commit 405243c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tx/builder/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ export const TX_SCHEMA = {
['lockPeriod', uInt],
['ttl', shortUInt],
['fee', fee],
['initiatorDelegateIds', FIELD_TYPES.string],
['responderDelegateIds', FIELD_TYPES.string],
['initiatorDelegateIds', addresses(...idTagToEncoding)],
['responderDelegateIds', addresses(...idTagToEncoding)],
['stateHash', FIELD_TYPES.binary, Encoding.State],
['nonce', shortUInt],
],
Expand Down
5 changes: 5 additions & 0 deletions test/unit/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ describe('Tx', () => {
expect(unpackTx(tx, Tag.ContractCreateTx).tx.fee).to.be.equal('78500000000000');
});

it('unpack and build ChannelCreateTx into the same value', () => {
const tx = 'tx_+IgyAqEBNMD0uYWndDrqF2Q8OIUWZ/gEi45vpwfg+cNOEVi9pL+JBWvHXi1jEAAAoQG5mrb34g29bneQLjNaFcH4OwVP0r9m9x6kYxpxiqN7EYkFa8deLWMQAAAAAQCGECcSfcAAwMCgOK3o2rLTFOY30p/4fMgaz3hG5WWTAcWknsu7ceLFmM0CERW42w==';
expect(buildTx(unpackTx(tx).tx)).to.be.equal(tx);
});

it('rejects if invalid transaction version', () => {
expect(() => buildTx({ tag: Tag.SpendTx, version: 5 } as any))
.to.throw(SchemaNotFoundError, 'Transaction serialization not implemented for SpendTx version 5');
Expand Down

0 comments on commit 405243c

Please sign in to comment.