cngn-typescript-library
Version:
A lightweight Typescript library to give you the best experience with managing your cNGN merchant account
77 lines (67 loc) • 2.57 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 = {
stages: [
{ duration: '1m', target: 200 }, // Ramp-up to 50 users in 1 minute
{ duration: '1m', target: 100 }, // Ramp-up to 300 users in 1 minute
{ duration: '2m', target: 100 }, // Hold at 300 users for 2 minutes
{ duration: '1m', target: 0 }, // Ramp-down to 0 users in 1 minute
],
thresholds: {
http_req_duration: ['p(95)<20000'], // 95% of requests should complete below 2s
'http_req_failed{status:200}': ['rate<0.01'], // Error rate should be less than 1%
},
};
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: 'atc',
originNetwork: 'base',
destinationAddress: '0x391e03868AfDa6ea9e0E3d4cDB5F6f09227d4B7C',
});
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 () {
swapAsset();
sleep(1);
}