mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
remove: remove old sidechain design features (#2060)
* remove federator_info RPC * remove util * update history * fix merge issues
This commit is contained in:
@@ -1,124 +0,0 @@
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { createCrossChainPayment, convertStringToHex, Payment } from '../../src'
|
||||
|
||||
describe('createCrossChainPayment', function () {
|
||||
it('successful xchain payment creation', function () {
|
||||
const payment: Payment = {
|
||||
TransactionType: 'Payment',
|
||||
Account: 'rRandom',
|
||||
Destination: 'rRandom2',
|
||||
Amount: '3489303',
|
||||
}
|
||||
const sidechainAccount = 'rSidechain'
|
||||
|
||||
const expectedPayment = {
|
||||
...payment,
|
||||
Memos: [
|
||||
{
|
||||
Memo: {
|
||||
MemoData: convertStringToHex(sidechainAccount),
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const resultPayment = createCrossChainPayment(payment, sidechainAccount)
|
||||
assert.deepEqual(resultPayment, expectedPayment)
|
||||
|
||||
// ensure that the original object wasn't modified
|
||||
assert.notDeepEqual(resultPayment, payment)
|
||||
})
|
||||
|
||||
it('successful xchain payment creation with memo', function () {
|
||||
const memo = {
|
||||
Memo: {
|
||||
MemoData: 'deadbeef',
|
||||
},
|
||||
}
|
||||
const payment: Payment = {
|
||||
TransactionType: 'Payment',
|
||||
Account: 'rRandom',
|
||||
Destination: 'rRandom2',
|
||||
Amount: '3489303',
|
||||
Memos: [memo],
|
||||
}
|
||||
const sidechainAccount = 'rSidechain'
|
||||
|
||||
const expectedPayment = {
|
||||
...payment,
|
||||
Memos: [
|
||||
{
|
||||
Memo: {
|
||||
MemoData: convertStringToHex(sidechainAccount),
|
||||
},
|
||||
},
|
||||
memo,
|
||||
],
|
||||
}
|
||||
|
||||
const resultPayment = createCrossChainPayment(payment, sidechainAccount)
|
||||
assert.deepEqual(resultPayment, expectedPayment)
|
||||
|
||||
// ensure that the original object wasn't modified
|
||||
assert.notDeepEqual(resultPayment, payment)
|
||||
})
|
||||
|
||||
it('removes TxnSignature', function () {
|
||||
const payment: Payment = {
|
||||
TransactionType: 'Payment',
|
||||
Account: 'rRandom',
|
||||
Destination: 'rRandom2',
|
||||
Amount: '3489303',
|
||||
TxnSignature: 'asodfiuaosdfuaosd',
|
||||
}
|
||||
const sidechainAccount = 'rSidechain'
|
||||
|
||||
const expectedPayment = {
|
||||
...payment,
|
||||
Memos: [
|
||||
{
|
||||
Memo: {
|
||||
MemoData: convertStringToHex(sidechainAccount),
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
delete expectedPayment.TxnSignature
|
||||
|
||||
const resultPayment = createCrossChainPayment(payment, sidechainAccount)
|
||||
assert.deepEqual(resultPayment, expectedPayment)
|
||||
|
||||
// ensure that the original object wasn't modified
|
||||
assert.notDeepEqual(resultPayment, payment)
|
||||
})
|
||||
|
||||
it('fails with 3 memos', function () {
|
||||
const payment: Payment = {
|
||||
TransactionType: 'Payment',
|
||||
Account: 'rRandom',
|
||||
Destination: 'rRandom2',
|
||||
Amount: '3489303',
|
||||
Memos: [
|
||||
{
|
||||
Memo: {
|
||||
MemoData: '2934723843ace',
|
||||
},
|
||||
},
|
||||
{
|
||||
Memo: {
|
||||
MemoData: '2934723843ace',
|
||||
},
|
||||
},
|
||||
{
|
||||
Memo: {
|
||||
MemoData: '2934723843ace',
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
assert.throws(() => {
|
||||
createCrossChainPayment(payment, 'rSidechain')
|
||||
}, /Cannot have more than 2 memos/u)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user