fix: add support for pseudo-transactions to hashSignedTx (#2588)

* add support for pseudo-transactions to hashSignedTx

* update changelog

* fix tests

* fix linter + tests
This commit is contained in:
Mayukha Vadari
2023-11-28 11:42:19 -08:00
committed by Caleb Kniffen
parent 9cdb60e26a
commit eefb52a9cb
3 changed files with 32 additions and 2 deletions

View File

@@ -4,7 +4,12 @@ import path from 'path'
import { assert } from 'chai'
import { encode } from 'ripple-binary-codec'
import { OfferCreate, Transaction, ValidationError } from '../../src'
import {
EnableAmendment,
OfferCreate,
Transaction,
ValidationError,
} from '../../src'
import {
hashStateTree,
hashTxTree,
@@ -166,6 +171,7 @@ describe('Hashes', function () {
it('Throw an error when hashing an unsigned transaction', function () {
const offerCreateWithNoSignature: OfferCreate = {
...(fixtures.tx.OfferCreateSell.result as OfferCreate),
SigningPubKey: undefined,
TxnSignature: undefined,
}
@@ -178,6 +184,7 @@ describe('Hashes', function () {
it('Throw when hashing an unsigned transaction blob', function () {
const encodedOfferCreateWithNoSignature: string = encode({
...fixtures.tx.OfferCreateSell.result,
SigningPubKey: undefined,
TxnSignature: undefined,
})
@@ -186,4 +193,22 @@ describe('Hashes', function () {
ValidationError,
)
})
it('hashSignedTx - pseudo-transaction', function () {
const transaction: EnableAmendment = {
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
Amendment:
'AE35ABDEFBDE520372B31C957020B34A7A4A9DC3115A69803A44016477C84D6E',
Fee: '0',
LedgerSequence: 84206081,
Sequence: 0,
SigningPubKey: '',
TransactionType: 'EnableAmendment',
}
assert.equal(
hashSignedTx(transaction),
'CA4562711E4679FE9317DD767871E90A404C7A8B84FAFD35EC2CF0231F1F6DAF',
)
})
})