remove integration testing

This commit is contained in:
Denis Angell
2023-02-06 10:48:27 -05:00
parent 8fbcb20129
commit e712d8fd8c
6 changed files with 11 additions and 258 deletions

View File

@@ -46,14 +46,6 @@ describe('fundWallet', function () {
)
})
it('can generate and fund wallets on vala net', async function () {
await generate_faucet_wallet_and_fund_again(
'wss://vala.ws.transia.co',
'vala.faucet.transia.co',
'/accounts',
)
})
it('can generate wallet on hooks v2 testnet', async function () {
const api = new Client('wss://hooks-testnet-v2.xrpl-labs.com')

View File

@@ -1,137 +1,24 @@
import { AccountSet, Client, Payment, TrustSet, Wallet } from 'xrpl-local'
import { Client, Wallet } from 'xrpl-local'
import serverUrl from './serverUrl'
import { fundAccount, ledgerAccept } from './utils'
import { fundAccount } from './utils'
export async function teardownClient(this: Mocha.Context): Promise<void> {
this.client.removeAllListeners()
this.client.disconnect()
}
// eslint-disable-next-line max-params -- need comments
async function initToken(
client: Client,
wallet: Wallet,
destination: Wallet,
gateway: Wallet,
): Promise<void> {
const atx: AccountSet = {
TransactionType: 'AccountSet',
Account: gateway.classicAddress,
SetFlag: 8,
}
const atxr = await client.submit(atx, {
wallet: gateway,
})
if (atxr.result.engine_result !== 'tesSUCCESS') {
// eslint-disable-next-line no-console -- happens only when something goes wrong
console.log(atxr)
}
await ledgerAccept(client)
const wtl: TrustSet = {
TransactionType: 'TrustSet',
Account: wallet.classicAddress,
LimitAmount: {
currency: 'USD',
issuer: gateway.classicAddress,
value: '100000',
},
}
const wtlr = await client.submit(wtl, {
wallet,
})
if (wtlr.result.engine_result !== 'tesSUCCESS') {
// eslint-disable-next-line no-console -- happens only when something goes wrong
console.log(wtlr)
}
await ledgerAccept(client)
const dtl: TrustSet = {
TransactionType: 'TrustSet',
Account: destination.classicAddress,
LimitAmount: {
currency: 'USD',
issuer: gateway.classicAddress,
value: '100000',
},
}
const dtlr = await client.submit(dtl, {
wallet: destination,
})
if (wtlr.result.engine_result !== 'tesSUCCESS') {
// eslint-disable-next-line no-console -- happens only when something goes wrong
console.log(dtlr)
}
await ledgerAccept(client)
const wp: Payment = {
TransactionType: 'Payment',
Account: gateway.classicAddress,
Destination: wallet.classicAddress,
Amount: {
currency: 'USD',
issuer: gateway.classicAddress,
value: '10000',
},
}
const wpr = await client.submit(wp, {
wallet: gateway,
})
if (wpr.result.engine_result !== 'tesSUCCESS') {
// eslint-disable-next-line no-console -- happens only when something goes wrong
console.log(wpr)
}
await ledgerAccept(client)
const dp: Payment = {
TransactionType: 'Payment',
Account: gateway.classicAddress,
Destination: destination.classicAddress,
Amount: {
currency: 'USD',
issuer: gateway.classicAddress,
value: '10000',
},
}
const dpr = await client.submit(dp, {
wallet: gateway,
})
if (dpr.result.engine_result !== 'tesSUCCESS') {
// eslint-disable-next-line no-console -- happens only when something goes wrong
console.log(dpr)
}
await ledgerAccept(client)
}
export async function setupClient(
this: Mocha.Context,
server = serverUrl,
token?: boolean | false,
): Promise<void> {
this.wallet = Wallet.generate()
this.destination = Wallet.generate()
this.gateway = Wallet.generate()
return new Promise<void>((resolve, reject) => {
this.client = new Client(server)
this.client
.connect()
.then(async () => {
await fundAccount(this.client, this.wallet)
await fundAccount(this.client, this.destination)
await fundAccount(this.client, this.gateway)
if (token) {
await initToken(
this.client,
this.wallet,
this.destination,
this.gateway,
)
}
resolve()
})
.catch(reject)

View File

@@ -12,10 +12,10 @@ const TIMEOUT = 20000
describe('EscrowCreate', function () {
this.timeout(TIMEOUT)
beforeEach(_.partial(setupClient, serverUrl, true))
beforeEach(_.partial(setupClient, serverUrl))
afterEach(teardownClient)
it('xrp test', async function () {
it('base', async function () {
// get the most recent close_time from the standalone container for finish after.
const CLOSE_TIME: number = (
await this.client.request({
@@ -28,7 +28,7 @@ describe('EscrowCreate', function () {
const tx: EscrowCreate = {
Account: this.wallet.classicAddress,
TransactionType: 'EscrowCreate',
Amount: '1000',
Amount: '10000',
Destination: wallet1.classicAddress,
FinishAfter: CLOSE_TIME + 2,
}
@@ -46,39 +46,4 @@ describe('EscrowCreate', function () {
1,
)
})
it('token test', async function () {
// get the most recent close_time from the standalone container for finish after.
const CLOSE_TIME: number = (
await this.client.request({
command: 'ledger',
ledger_index: 'validated',
})
).result.ledger.close_time
const tx: EscrowCreate = {
Account: this.wallet.classicAddress,
TransactionType: 'EscrowCreate',
Amount: {
currency: 'USD',
issuer: this.gateway.classicAddress,
value: '1000',
},
Destination: this.destination.classicAddress,
FinishAfter: CLOSE_TIME + 2,
}
await testTransaction(this.client, tx, this.wallet)
// check that the object was actually created
assert.equal(
(
await this.client.request({
command: 'account_objects',
account: this.wallet.classicAddress,
})
).result.account_objects.length,
1,
)
})
})

View File

@@ -12,10 +12,10 @@ const { hashPaymentChannel } = hashes
describe('PaymentChannelClaim', function () {
this.timeout(TIMEOUT)
beforeEach(_.partial(setupClient, serverUrl, true))
beforeEach(_.partial(setupClient, serverUrl))
afterEach(teardownClient)
it('xrp test', async function () {
it('base', async function () {
const wallet2 = await generateFundedWallet(this.client)
const paymentChannelCreate: PaymentChannelCreate = {
TransactionType: 'PaymentChannelCreate',
@@ -46,43 +46,4 @@ describe('PaymentChannelClaim', function () {
await testTransaction(this.client, paymentChannelClaim, this.wallet)
})
it('token test', async function () {
const paymentChannelCreate: PaymentChannelCreate = {
TransactionType: 'PaymentChannelCreate',
Account: this.wallet.classicAddress,
Amount: {
currency: 'USD',
issuer: this.gateway.classicAddress,
value: '100',
},
Destination: this.destination.classicAddress,
SettleDelay: 86400,
PublicKey: this.wallet.publicKey,
}
const paymentChannelResponse = await this.client.submit(
paymentChannelCreate,
{ wallet: this.wallet },
)
await testTransaction(this.client, paymentChannelCreate, this.wallet)
const paymentChannelClaim: PaymentChannelClaim = {
Account: this.wallet.classicAddress,
TransactionType: 'PaymentChannelClaim',
Channel: hashPaymentChannel(
this.wallet.classicAddress,
this.destination.classicAddress,
paymentChannelResponse.result.tx_json.Sequence ?? 0,
),
Amount: {
currency: 'USD',
issuer: this.gateway.classicAddress,
value: '100',
},
}
await testTransaction(this.client, paymentChannelClaim, this.wallet)
})
})

View File

@@ -11,10 +11,10 @@ const TIMEOUT = 20000
describe('PaymentChannelCreate', function () {
this.timeout(TIMEOUT)
beforeEach(_.partial(setupClient, serverUrl, true))
beforeEach(_.partial(setupClient, serverUrl))
afterEach(teardownClient)
it('xrp test', async function () {
it('base', async function () {
const wallet2 = await generateFundedWallet(this.client)
const paymentChannelCreate: PaymentChannelCreate = {
TransactionType: 'PaymentChannelCreate',
@@ -27,19 +27,4 @@ describe('PaymentChannelCreate', function () {
await testTransaction(this.client, paymentChannelCreate, this.wallet)
})
it('token test', async function () {
const paymentChannelCreate: PaymentChannelCreate = {
TransactionType: 'PaymentChannelCreate',
Account: this.wallet.classicAddress,
Amount: {
currency: 'USD',
issuer: this.gateway.classicAddress,
value: '100',
},
Destination: this.destination.classicAddress,
SettleDelay: 86400,
PublicKey: this.wallet.publicKey,
}
await testTransaction(this.client, paymentChannelCreate, this.wallet)
})
})

View File

@@ -12,10 +12,10 @@ const { hashPaymentChannel } = hashes
describe('PaymentChannelFund', function () {
this.timeout(TIMEOUT)
beforeEach(_.partial(setupClient, serverUrl, true))
beforeEach(_.partial(setupClient, serverUrl))
afterEach(teardownClient)
it('xrp test', async function () {
it('base', async function () {
const wallet2 = await generateFundedWallet(this.client)
const paymentChannelCreate: PaymentChannelCreate = {
TransactionType: 'PaymentChannelCreate',
@@ -43,43 +43,6 @@ describe('PaymentChannelFund', function () {
Amount: '100',
}
await testTransaction(this.client, paymentChannelFund, this.wallet)
})
it('token test', async function () {
const paymentChannelCreate: PaymentChannelCreate = {
TransactionType: 'PaymentChannelCreate',
Account: this.wallet.classicAddress,
Amount: {
currency: 'USD',
issuer: this.gateway.classicAddress,
value: '100',
},
Destination: this.destination.classicAddress,
SettleDelay: 86400,
PublicKey: this.wallet.publicKey,
}
const paymentChannelResponse = await this.client.submit(
paymentChannelCreate,
{ wallet: this.wallet },
)
await testTransaction(this.client, paymentChannelCreate, this.wallet)
const paymentChannelFund: PaymentChannelFund = {
Account: this.wallet.classicAddress,
TransactionType: 'PaymentChannelFund',
Channel: hashPaymentChannel(
this.wallet.classicAddress,
this.destination.classicAddress,
paymentChannelResponse.result.tx_json.Sequence ?? 0,
),
Amount: {
currency: 'USD',
issuer: this.gateway.classicAddress,
value: '100',
},
}
await testTransaction(this.client, paymentChannelFund, this.wallet)
})
})