-
Notifications
You must be signed in to change notification settings - Fork 15
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: Btc vault swap bouncer test can open a private channel #5410
Changes from all commits
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ import { | |
} from '../shared/utils'; | ||
import { getChainflipApi, observeEvent } from '../shared/utils/substrate'; | ||
import { getBalance } from '../shared/get_balance'; | ||
import { jsonRpc } from '../shared/json_rpc'; | ||
|
||
/* eslint-disable @typescript-eslint/no-use-before-define */ | ||
export const testBtcVaultSwap = new ExecutableTest('Btc-Vault-Swap', main, 100); | ||
|
@@ -51,6 +52,7 @@ async function buildAndSendBtcVaultSwap( | |
|
||
assert.strictEqual(vaultSwapDetails.chain, 'Bitcoin'); | ||
testBtcVaultSwap.debugLog('nulldata_utxo:', vaultSwapDetails.nulldata_utxo); | ||
testBtcVaultSwap.debugLog('deposit_address:', vaultSwapDetails.deposit_address); | ||
|
||
// The `createRawTransaction` function will add the op codes, so we have to remove them here. | ||
const nullDataWithoutOpCodes = vaultSwapDetails.nulldata_utxo.replace('0x', '').substring(4); | ||
|
@@ -112,8 +114,25 @@ async function testVaultSwap(depositAmountBtc: number, brokerUri: string, destin | |
testBtcVaultSwap.log(`Balance increased, Vault Swap Complete`); | ||
} | ||
|
||
async function openPrivateBtcChannel(brokerUri: string) { | ||
// TODO: Use chainflip SDK instead so we can support any broker uri | ||
assert.strictEqual(brokerUri, '//BROKER_1', 'Support for other brokers is not implemented'); | ||
|
||
// TODO: use chainflip SDK to check if the channel is already open | ||
try { | ||
await jsonRpc('broker_open_private_btc_channel', [], 'http://127.0.0.1:10997'); | ||
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. Does the jsonRpc util not have a constant (or similar) to avoid having to explicitly pass the api url/port?? 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. Didn't seem worth adding a broker constant when the code will be replaced later by the chainflip SDK. |
||
testBtcVaultSwap.log('Private Btc channel opened'); | ||
} catch (error) { | ||
// We expect this to fail if the channel already exists from a previous run | ||
testBtcVaultSwap.debugLog('Failed to open private Btc channel', error); | ||
kylezs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
async function main() { | ||
const btcDepositAmount = 0.1; | ||
const brokerUri = '//BROKER_1'; | ||
|
||
await openPrivateBtcChannel(brokerUri); | ||
|
||
await testVaultSwap(btcDepositAmount, '//BROKER_1', 'Flip'); | ||
await testVaultSwap(btcDepositAmount, brokerUri, 'Flip'); | ||
} |
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.
we use this pattern a lot here, seems like it should be a util
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.
I can't see a good way to make it a util. Same problem we hit in the LP api.
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.
#5412