Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Jul 12, 2023
1 parent 2032495 commit 9c3b1dd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,15 @@ describe('Update Masternode', () => {
await expect(promise).rejects.toThrow(`operatorAddress (${operatorAddress}) does not refer to a P2PKH or P2WPKH address`)
}

{
const rewardAddress = await client.wallet.getNewAddress('', AddressType.P2SH_SEGWIT)
const promise = client.masternode.updateMasternode(masternodeId, {
rewardAddress
})
await expect(promise).rejects.toThrow(RpcApiError)
await expect(promise).rejects.toThrow('Reward address must be P2PKH or P2WPKH type\', code: -32600, method: updatemasternode')
}
// Updated: P2SH is allowed for rewardAddress - https://github.com/DeFiCh/ain/pull/1664
// {
// const rewardAddress = await client.wallet.getNewAddress('', AddressType.P2SH_SEGWIT)
// const promise = client.masternode.updateMasternode(masternodeId, {
// rewardAddress
// })
// await expect(promise).rejects.toThrow(RpcApiError)
// await expect(promise).rejects.toThrow('Reward address must be P2PKH or P2WPKH type\', code: -32600, method: updatemasternode')
// }
})

it('should be failed as invalid address is not allowed', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,20 +574,21 @@ describe('UpdateMasternode', () => {
await expect(promise).rejects.toThrow(DeFiDRpcError)
await expect(promise).rejects.toThrow("DeFiDRpcError: 'bad-txns-customtx, UpdateMasternodeTx: Operator address must be P2PKH or P2WPKH type (code 16)', code: -26")
}
{
const address = await container.getNewAddress('', 'p2sh-segwit')
const addressDest: P2SH = P2SH.fromAddress(RegTest, address, P2SH)
const addressDestHex = addressDest.hex

const updateMasternode: UpdateMasternode = {
nodeId: masternodeId,
updates: [{ updateType: 0x03, address: { addressType: 0x02, addressPubKeyHash: addressDestHex } }]
}
const txn: TransactionSegWit = await builder.masternode.update(updateMasternode, script)
const promise = sendTransaction(container, txn)
await expect(promise).rejects.toThrow(DeFiDRpcError)
await expect(promise).rejects.toThrow("DeFiDRpcError: 'bad-txns-customtx, UpdateMasternodeTx: Reward address must be P2PKH or P2WPKH type (code 16)', code: -26")
}
// Updated: P2SH is allowed - https://github.com/DeFiCh/ain/pull/1664
// {
// const address = await container.getNewAddress('', 'p2sh-segwit')
// const addressDest: P2SH = P2SH.fromAddress(RegTest, address, P2SH)
// const addressDestHex = addressDest.hex

// const updateMasternode: UpdateMasternode = {
// nodeId: masternodeId,
// updates: [{ updateType: 0x03, address: { addressType: 0x02, addressPubKeyHash: addressDestHex } }]
// }
// const txn: TransactionSegWit = await builder.masternode.update(updateMasternode, script)
// const promise = sendTransaction(container, txn)
// await expect(promise).rejects.toThrow(DeFiDRpcError)
// await expect(promise).rejects.toThrow("DeFiDRpcError: 'bad-txns-customtx, UpdateMasternodeTx: Reward address must be P2PKH or P2WPKH type (code 16)', code: -26")
// }
})

it('should be failed as invalid address is not allowed', async () => {
Expand Down Expand Up @@ -620,7 +621,7 @@ describe('UpdateMasternode', () => {
const txn: TransactionSegWit = await builder.masternode.update(updateMasternode, script)
const promise = sendTransaction(container, txn)
await expect(promise).rejects.toThrow(DeFiDRpcError)
await expect(promise).rejects.toThrow('DeFiDRpcError: \'bad-txns-customtx, UpdateMasternodeTx: Reward address must be P2PKH or P2WPKH type (code 16)\', code: -26')
await expect(promise).rejects.toThrow('DeFiDRpcError: \'bad-txns-customtx, UpdateMasternodeTx: Reward address must be P2SH, P2PKH or P2WPKH type (code 16)\', code: -26')
}
})

Expand Down

0 comments on commit 9c3b1dd

Please sign in to comment.