mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
test: add AMM integration tests (#2471)
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import { assert } from 'chai'
|
||||
|
||||
import {
|
||||
AMMDeposit,
|
||||
AMMDepositFlags,
|
||||
Client,
|
||||
Currency,
|
||||
SignerListSet,
|
||||
Wallet,
|
||||
XChainBridge,
|
||||
@@ -11,11 +14,20 @@ import {
|
||||
import serverUrl from './serverUrl'
|
||||
import {
|
||||
GENESIS_ACCOUNT,
|
||||
createAMMPool,
|
||||
fundAccount,
|
||||
generateFundedWallet,
|
||||
testTransaction,
|
||||
} from './utils'
|
||||
|
||||
export interface TestAMMPool {
|
||||
issuerWallet: Wallet
|
||||
lpWallet: Wallet
|
||||
testWallet: Wallet
|
||||
asset: Currency
|
||||
asset2: Currency
|
||||
}
|
||||
|
||||
interface TestBridge {
|
||||
xchainBridge: XChainBridge
|
||||
witness: Wallet
|
||||
@@ -66,6 +78,33 @@ export async function setupClient(
|
||||
})
|
||||
}
|
||||
|
||||
export async function setupAMMPool(client: Client): Promise<TestAMMPool> {
|
||||
const testAMMPool = await createAMMPool(client)
|
||||
const { issuerWallet, lpWallet, asset, asset2 } = testAMMPool
|
||||
|
||||
const testWallet = await generateFundedWallet(client)
|
||||
|
||||
// Need to deposit (be an LP) to make bid/vote/withdraw eligible in tests for testContext.wallet
|
||||
const ammDepositTx: AMMDeposit = {
|
||||
TransactionType: 'AMMDeposit',
|
||||
Account: testWallet.classicAddress,
|
||||
Asset: asset,
|
||||
Asset2: asset2,
|
||||
Amount: '1000',
|
||||
Flags: AMMDepositFlags.tfSingleAsset,
|
||||
}
|
||||
|
||||
await testTransaction(client, ammDepositTx, testWallet)
|
||||
|
||||
return {
|
||||
issuerWallet,
|
||||
lpWallet,
|
||||
testWallet,
|
||||
asset,
|
||||
asset2,
|
||||
}
|
||||
}
|
||||
|
||||
export async function setupBridge(client: Client): Promise<TestBridge> {
|
||||
const doorAccount = await generateFundedWallet(client)
|
||||
const signatureReward = '200'
|
||||
|
||||
Reference in New Issue
Block a user