-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(rawtx): add decodeRawTransaction function #1963
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
537942e
feat: add decodeRawTransaction function
fe783d3
chore: check all the properties of of decoded transation in test
8d4e5c1
chore: add doc for decodeRawTransaction
3f70535
chore: change individual assertion to object assertion for testing
ca79d06
chore: Use proper container for decodeRawTransaction test
DocteurPing 6edd7f0
chore: remove useless waitForWalletMaturity in decodeRawTransaction test
DocteurPing 6308818
chore: fix test name for decoderawtransaction
50c1e3f
chore: remove useless objectContaining for decoderawtransaction test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
101 changes: 101 additions & 0 deletions
101
packages/jellyfish-api-core/__tests__/category/rawtx/decodeRawTransaction.test.ts
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,101 @@ | ||
import { MasterNodeRegTestContainer } from '@defichain/testcontainers/dist/index' | ||
import { ContainerAdapterClient } from '../../container_adapter_client' | ||
import { RpcApiError } from '../../../src' | ||
|
||
describe('poolpair update', () => { | ||
const container = new MasterNodeRegTestContainer() | ||
DocteurPing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const client = new ContainerAdapterClient(container) | ||
|
||
beforeAll(async () => { | ||
await container.start() | ||
await container.waitForWalletCoinbaseMaturity() | ||
DocteurPing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
|
||
afterAll(async () => { | ||
await container.stop() | ||
}) | ||
|
||
it('should decode a witness transaction', async () => { | ||
const encrawtx = '010000000001010000000000000072c1a6a246ae63f74f931e8365e15a089c68d61900000000000000000000ffffffff0100e1f50500000000000102616100000000' | ||
const decrawtx = await client.rawtx.decodeRawTransaction(encrawtx, true) | ||
|
||
expect(decrawtx).toStrictEqual({ | ||
txid: 'd006b4ece5d4adbd6f46b3a6f65f4a230caf6c44d8510e4340d0f26b7ceeb44a', | ||
hash: '23f0c1f68f0a43bb434494933a5a0f6f9636261f33b036b7700d96e264aceeda', | ||
version: 1, | ||
size: 66, | ||
vsize: 62, | ||
weight: 246, | ||
locktime: 0, | ||
vin: [ | ||
expect.objectContaining({ | ||
txid: '000000000019d6689c085ae165831e934ff763ae46a2a6c17200000000000000', | ||
vout: 0, | ||
scriptSig: | ||
expect.objectContaining({ | ||
asm: '', | ||
hex: '' | ||
}), | ||
txinwitness: ['6161'], | ||
sequence: 4294967295 | ||
}) | ||
], | ||
vout: [ | ||
expect.objectContaining({ | ||
value: 1, | ||
n: 0, | ||
scriptPubKey: | ||
expect.objectContaining({ | ||
asm: '', | ||
hex: '', | ||
type: 'nonstandard' | ||
}) | ||
}) | ||
] | ||
}) | ||
}) | ||
|
||
it('should throw an error when for decode as non-witness a witness transaction', async () => { | ||
const encrawtx = '010000000001010000000000000072c1a6a246ae63f74f931e8365e15a089c68d61900000000000000000000ffffffff0100e1f50500000000000102616100000000' | ||
await expect(client.rawtx.decodeRawTransaction(encrawtx, false)).rejects.toThrow(RpcApiError) | ||
}) | ||
|
||
it('should decode a non-witness transaction', async () => { | ||
const encrawtx = '01000000010000000000000072c1a6a246ae63f74f931e8365e15a089c68d61900000000000000000000ffffffff0100e1f505000000000000000000' | ||
const decrawtx = await client.rawtx.decodeRawTransaction(encrawtx, true) | ||
|
||
expect(decrawtx).toStrictEqual({ | ||
txid: 'd006b4ece5d4adbd6f46b3a6f65f4a230caf6c44d8510e4340d0f26b7ceeb44a', | ||
hash: 'd006b4ece5d4adbd6f46b3a6f65f4a230caf6c44d8510e4340d0f26b7ceeb44a', | ||
version: 1, | ||
size: 60, | ||
vsize: 60, | ||
weight: 240, | ||
locktime: 0, | ||
vin: [ | ||
expect.objectContaining({ | ||
txid: '000000000019d6689c085ae165831e934ff763ae46a2a6c17200000000000000', | ||
vout: 0, | ||
scriptSig: | ||
expect.objectContaining({ | ||
asm: '', | ||
hex: '' | ||
}), | ||
sequence: 4294967295 | ||
}) | ||
], | ||
vout: [ | ||
expect.objectContaining({ | ||
value: 1, | ||
n: 0, | ||
scriptPubKey: | ||
expect.objectContaining({ | ||
asm: '', | ||
hex: '', | ||
type: 'nonstandard' | ||
}) | ||
}) | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be explicitly defined instead of |
||
}) | ||
}) | ||
}) |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong description