-
Notifications
You must be signed in to change notification settings - Fork 562
fix: make submitAndWait fail faster with tem errors
#2948
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
Changes from all commits
bdd40d4
e26bfa6
b72e764
af79250
072326b
c59b4d7
6df1448
f658e4c
8aeea38
1da58da
d5e630c
597b51d
31bf926
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { XrplError } from '../../src' | ||
|
Collaborator
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. This file (
Collaborator
Author
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. It's easier to test this sort of thing with a unit test where I can control the fixture as opposed to with an integration test. |
||
| import { Transaction } from '../../src/models/transactions' | ||
| import rippled from '../fixtures/rippled' | ||
| import { | ||
| setupClient, | ||
| teardownClient, | ||
| type XrplTestContext, | ||
| } from '../setupClient' | ||
| import { assertRejects } from '../testUtils' | ||
|
|
||
| describe('client.submitAndWait', function () { | ||
| let testContext: XrplTestContext | ||
|
|
||
| beforeEach(async () => { | ||
| testContext = await setupClient() | ||
| }) | ||
| afterEach(async () => teardownClient(testContext)) | ||
|
|
||
| const signedTransaction: Transaction = { | ||
| TransactionType: 'Payment', | ||
| Sequence: 1, | ||
| LastLedgerSequence: 12312, | ||
| Amount: '20000000', | ||
| Fee: '12', | ||
| SigningPubKey: | ||
| '030E58CDD076E798C84755590AAF6237CA8FAE821070A59F648B517A30DC6F589D', | ||
| TxnSignature: | ||
| '3045022100B3D311371EDAB371CD8F2B661A04B800B61D4B132E09B7B0712D3B2F11B1758302203906B44C4A150311D74FF6A35B146763C0B5B40AC30BD815113F058AA17B3E63', | ||
| Account: 'rhvh5SrgBL5V8oeV9EpDuVszeJSSCEkbPc', | ||
| Destination: 'rQ3PTWGLCbPz8ZCicV5tCX3xuymojTng5r', | ||
| } | ||
|
|
||
| it('should exit early with a tem error', async function () { | ||
| const signedTx = { ...signedTransaction } | ||
|
|
||
| testContext.mockRippled!.addResponse('submit', rippled.submit.temError) | ||
|
|
||
| await assertRejects( | ||
| testContext.client.submitAndWait(signedTx), | ||
| XrplError, | ||
| 'Transaction failed, temMALFORMED: Malformed transaction.', | ||
| ) | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "id": 0, | ||
| "status": "success", | ||
| "type": "response", | ||
| "result": { | ||
| "success": false, | ||
| "engine_result": "temMALFORMED", | ||
| "engine_result_code": -299, | ||
| "engine_result_message": "Malformed transaction.", | ||
| "tx_blob": "1200002280000000240000016861D4838D7EA4C6800000000000000000000000000055534400000000004B4E9C06F24296074F7BC48F92A97916C6DC5EA9684000000000002710732103AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB7446304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F858081144B4E9C06F24296074F7BC48F92A97916C6DC5EA983143E9D4A2B8AA0780F682D136F7A56D6724EF53754", | ||
| "tx_json": { | ||
| "Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", | ||
| "Amount": { | ||
| "currency": "USD", | ||
| "issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", | ||
| "value": "1" | ||
| }, | ||
| "Destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", | ||
| "Fee": "10000", | ||
| "Flags": 2147483648, | ||
| "Sequence": 360, | ||
| "SigningPubKey": "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB", | ||
| "TransactionType": "Payment", | ||
| "TxnSignature": "304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F8580", | ||
| "hash": "4D5D90890F8D49519E4151938601EF3D0B30B16CD6A519D9C99102C9FA77F7E0" | ||
| } | ||
| } | ||
| } |
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.
This is just moved, no code change