Skip to content

Commit 38aae4e

Browse files
authored
Merge pull request #53 from Zoints/misc-error-checking
[js] More error decoding checks
2 parents 823230c + b54205c commit 38aae4e

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

js/test/errors.test.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from 'chai';
22
import 'mocha';
3-
import { extractErrorId, parseError } from '../src';
3+
import { extractErrorId, parseError, StakingErrors } from '../src';
44

55
describe('Errors', () => {
66
it('should be equal', () => {
@@ -24,12 +24,31 @@ describe('Errors', () => {
2424
expect(extractErrorId(new Error('custom program error: 0x0'))).to.eql(
2525
0
2626
);
27+
expect(extractErrorId(new Error('custom program error: 0x09'))).to.eql(
28+
9
29+
);
2730
expect(
2831
extractErrorId(
2932
new Error(
3033
'failed to send transaction: Transaction simulation failed: Error processing Instruction 1: custom program error: 0x11'
3134
)
3235
)
3336
).to.eql(17);
37+
38+
for (
39+
let i = 0;
40+
i < StakingErrors.SecondaryAuthorityKeysDoNotMatch;
41+
i++
42+
) {
43+
expect(
44+
parseError(
45+
new Error(
46+
`custom program error: 0x${Buffer.from([i]).toString(
47+
'hex'
48+
)}`
49+
)
50+
).message
51+
).to.contain(StakingErrors[i]);
52+
}
3453
});
3554
});

0 commit comments

Comments
 (0)