Resolve "feat(Primitives): Have Bytes Primitive extends Uint8Array (if possible)"
This commit is contained in:
@@ -17,11 +17,11 @@ describe('Success cases', () => {
|
||||
{
|
||||
raw: Bytes.fromHex(
|
||||
'76a914876fbb82ec05caa6af7a3b5e5a983aae6c6cc6d688ac',
|
||||
).toBytes(),
|
||||
).toUint8Array(),
|
||||
representations: {
|
||||
bytes: Bytes.fromHex(
|
||||
'76a914876fbb82ec05caa6af7a3b5e5a983aae6c6cc6d688ac',
|
||||
).toBytes(),
|
||||
).toUint8Array(),
|
||||
asm: 'OP_DUP\nOP_HASH160\nOP_PUSHBYTES_20\n0x876fbb82ec05caa6af7a3b5e5a983aae6c6cc6d6\nOP_EQUALVERIFY\nOP_CHECKSIG',
|
||||
hex: '76a914876fbb82ec05caa6af7a3b5e5a983aae6c6cc6d688ac',
|
||||
},
|
||||
@@ -38,19 +38,19 @@ describe('Success cases', () => {
|
||||
fromMethods.forEach(({ name, key }) => {
|
||||
it.each(testCases)(`${name}()`, ({ raw, representations }) => {
|
||||
const script = Script[name](representations[key]);
|
||||
expect(script.toRaw()).toStrictEqual(raw);
|
||||
expect(script.toRaw()).toEqual(raw);
|
||||
});
|
||||
});
|
||||
|
||||
// Test generic from method
|
||||
it.each(testCases)('from(Uint8Array)', ({ raw, representations }) => {
|
||||
const script = Script.from(representations.bytes);
|
||||
expect(script.toRaw()).toStrictEqual(raw);
|
||||
expect(script.toRaw()).toEqual(raw);
|
||||
});
|
||||
|
||||
it.each(testCases)('from(string)', ({ raw, representations }) => {
|
||||
const script = Script.from(representations.hex);
|
||||
expect(script.toRaw()).toStrictEqual(raw);
|
||||
expect(script.toRaw()).toEqual(raw);
|
||||
});
|
||||
|
||||
// Test to methods with their respective types
|
||||
@@ -63,14 +63,14 @@ describe('Success cases', () => {
|
||||
toMethods.forEach(({ name, key }) => {
|
||||
it.each(testCases)(`${name}()`, ({ raw, representations }) => {
|
||||
const script = Script.fromRaw(raw);
|
||||
expect(script[name]()).toStrictEqual(representations[key]);
|
||||
expect(script[name]()).toEqual(representations[key]);
|
||||
});
|
||||
});
|
||||
|
||||
// Test fromRaw specifically
|
||||
it.each(testCases)('fromRaw() creates correct instance', ({ raw }) => {
|
||||
const script = Script.fromRaw(raw);
|
||||
expect(script.toRaw()).toStrictEqual(raw);
|
||||
expect(script.toRaw()).toEqual(raw);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user