cngn-typescript-library
Version:
A lightweight Typescript library to give you the best experience with managing your cNGN merchant account
89 lines (73 loc) • 2.24 kB
JavaScript
import http from 'k6/http';
import { check, sleep } from 'k6';
const BASE_URL = 'https://staging.api.wrapcbdc.com/v1/api';
const API_KEY = 'cngn_live_gMtkVsc8AeHDg1nfg2lRl76o2lfZ6MpudNck38fMowEoBEeTfM2';
export const options = {
vus: 20,
duration: '30s',
};
const headers = {
Authorization: `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
};
const withdraw = () => {
const payload = JSON.stringify({
address: 'GAKRER5S7DNP36JOVNFFD22QPPRGN5P3RY44IQMMPMRLIGC6SVPKHIJP',
network: 'xbn',
amount: 150,
});
const response = http.post(`${BASE_URL}/withdraw`, payload, {
headers
});
check(response, {
'Withdraw status is 200': (r) => r.status === 200,
});
console.info('Withdraw Response:', response.body);
};
const verifyWithdrawal = () => {
const response = http.get(`${BASE_URL}/withdraw/verify/9bc35d4b-1f34-471a-b403-3e0f8dbcc4f4`, {
headers
});
check(response, {
'Verify Withdrawal status is 200': (r) => r.status === 200,
});
console.info('Verify Withdrawal Response:', response.body);
};
const redeemAsset = () => {
const payload = JSON.stringify({
amount: 1000000,
accountNumber: '3069839406',
bankCode: '011',
});
const response = http.post(`${BASE_URL}/redeemAsset`, payload, {
headers
});
check(response, {
'Redeem Asset status is 200': (r) => r.status === 200,
});
console.info('Redeem Asset Response:', response.body);
};
const swapAsset = () => {
const payload = JSON.stringify({
destinationNetwork: 'bsc',
originNetwork: 'atc',
destinationAddress: '0x8867D4efC159Cc7abEd4f700b2475B67bD11d0c8',
});
const response = http.post(`${BASE_URL}/swap`, payload, {
headers
});
check(response, {
'Swap Asset status is 200': (r) => r.status === 200,
});
console.info('Swap Asset Response:', response.body);
};
export default function () {
withdraw();
sleep(1);
verifyWithdrawal();
sleep(1);
redeemAsset();
sleep(1);
swapAsset();
sleep(1);
}