-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rpc): enable batch request (#449)
- Loading branch information
Showing
12 changed files
with
541 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
packages/ckb-sdk-core/__tests__/signWitnessGroup/fixtures.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"empty witnesses": { | ||
"privateKey": "0xdcec27d0d975b0378471183a03f7071dea8532aaf968be796719ecd20af6988f", | ||
"transactionHash": "0x4a4bcfef1b7448e27edf533df2f1de9f56be05eba645fb83f42d55816797ad2a", | ||
"witnesses": [], | ||
"exception": "WitnessGroup cannot be empty" | ||
}, | ||
"first one is witness args": { | ||
"privateKey": "0xdcec27d0d975b0378471183a03f7071dea8532aaf968be796719ecd20af6988f", | ||
"transactionHash": "0x4a4bcfef1b7448e27edf533df2f1de9f56be05eba645fb83f42d55816797ad2a", | ||
"witnesses": [ | ||
"0x", | ||
{ | ||
"lock": "", | ||
"inputType": "", | ||
"outputType": "" | ||
} | ||
], | ||
"exception": "The first witness in the group should be type of WitnessArgs" | ||
}, | ||
"Should pass": { | ||
"privateKey": "0xdcec27d0d975b0378471183a03f7071dea8532aaf968be796719ecd20af6988f", | ||
"transactionHash": "0x4a4bcfef1b7448e27edf533df2f1de9f56be05eba645fb83f42d55816797ad2a", | ||
"witnesses": [ | ||
{ | ||
"lock": "", | ||
"inputType": "", | ||
"outputType": "" | ||
}, | ||
{ | ||
"lock": "", | ||
"inputType": "", | ||
"outputType": "" | ||
} | ||
], | ||
"expected": [ | ||
"0x55000000100000005500000055000000410000005bc073bf55db333d5680ddf36e4814b9ce2118cfe4504f95c7d3e9a7548e16886cf1a1481fd80ce70d5e19108a43fd17fa32aad0d46c30c3410001ed2934ad2f00", | ||
{ | ||
"lock": "", | ||
"inputType": "", | ||
"outputType": "" | ||
} | ||
] | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/ckb-sdk-core/__tests__/signWitnessGroup/index.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const signWitnessGroup = require('../../lib/signWitnessGroup').default | ||
const fixtures = require('./fixtures.json') | ||
|
||
describe('test sign witness group', () => { | ||
const fixtureTable = Object.entries( | ||
fixtures, | ||
).map(([title, { privateKey, transactionHash, witnesses, expected, exception }]) => [ | ||
title, | ||
privateKey, | ||
transactionHash, | ||
witnesses, | ||
exception, | ||
expected, | ||
]) | ||
|
||
test.each(fixtureTable)('%s', (_title, privateKey, transactionHash, witnesses, exception, expected) => { | ||
expect.assertions(1) | ||
if (exception !== undefined) { | ||
expect(() => signWitnessGroup(privateKey, transactionHash, witnesses)).toThrowError(exception) | ||
} else if (privateKey !== undefined) { | ||
const signedWitnessGroup = signWitnessGroup(privateKey, transactionHash, witnesses) | ||
expect(signedWitnessGroup).toEqual(expected) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.