wormhole/relayer/spy_relayer/src/monitor/walletMonitor.test.ts

95 lines
3.2 KiB
TypeScript
Raw Normal View History

require("../helpers/loadConfig");
process.env.LOG_DIR = ".";
2022-08-11 14:47:50 -07:00
import { CHAIN_ID_TERRA, CHAIN_ID_TERRA2 } from "@certusone/wormhole-sdk";
import { jest, test } from "@jest/globals";
import { LCDClient } from "@terra-money/terra.js";
import { ChainConfigInfo } from "../configureEnv";
import { calcLocalAddressesTerra, pullTerraBalance } from "./walletMonitor";
// import { pullEVMBalance } from "./walletMonitor";
jest.setTimeout(300000);
// const bscChainConfig: ChainConfigInfo = {
// chainId: CHAIN_ID_BSC,
// chainName: "BSC",
// nativeCurrencySymbol: "BNB",
// nodeUrl: "https://bsc-dataseed.binance.org",
// tokenBridgeAddress: "0xB6F6D86a8f9879A9c87f643768d9efc38c1Da6E7",
// wrappedAsset: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
// };
// const bscPublicKey = "0xB6F6D86a8f9879A9c87f643768d9efc38c1Da6E7"; // Token Bridge
// const bscTokens = [
// "0xfA54fF1a158B5189Ebba6ae130CEd6bbd3aEA76e", // SOL
// "0x4DB5a66E937A9F4473fA95b1cAF1d1E1D62E29EA", // WETH
// "0x156ab3346823B651294766e23e6Cf87254d68962", // LUNA
// "0x3d4350cD54aeF9f9b2C29435e0fa809957B3F30a", // UST
// "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", // WBNB
// "0xc836d8dC361E44DbE64c4862D55BA041F88Ddd39", // WMATIC
// "0x96412902aa9aFf61E13f085e70D3152C6ef2a817", // WAVAX
// "0x6c6D604D3f07aBE287C1A3dF0281e999A83495C0", // wROSE
// "0xbF8413EE8612E0E4f66Aa63B5ebE27f3C5883d47", // WFTM
// "0xB04906e95AB5D797aDA81508115611fee694c2b3", // USDC
// "0x524bC91Dc82d6b90EF29F76A3ECAaBAffFD490Bc", // USDT
// ];
// test("should pull EVM token balances", async () => {
// for (let address of bscTokens) {
// const balance = await pullEVMBalance(bscChainConfig, bscPublicKey, address);
// console.log(balance);
// expect(balance).toBeTruthy();
// }
// });
2022-08-11 14:47:50 -07:00
const terraClassicChainConfig: ChainConfigInfo = {
chainId: CHAIN_ID_TERRA,
2022-08-11 14:47:50 -07:00
chainName: "Terra Classic",
nativeCurrencySymbol: "LUNC",
nodeUrl: "https://columbus-fcd.terra.dev",
tokenBridgeAddress: "terra10nmmwe8r3g99a9newtqa7a75xfgs2e8z87r2sf",
terraName: "mainnet",
terraChainId: "columbus-5",
terraCoin: "uluna",
2022-08-11 14:47:50 -07:00
terraGasPriceUrl: "https://columbus-fcd.terra.dev/v1/txs/gas_prices",
};
const supportedTokens = require("../../config/mainnet/supportedTokens.json");
2022-08-11 14:47:50 -07:00
test("should pull Terra Classic token balances", async () => {
if (
!(
2022-08-11 14:47:50 -07:00
terraClassicChainConfig.terraChainId &&
terraClassicChainConfig.terraCoin &&
terraClassicChainConfig.terraGasPriceUrl &&
terraClassicChainConfig.terraName
)
) {
2022-08-11 14:47:50 -07:00
throw new Error(
"Terra Classic relay was called without proper instantiation."
);
}
const lcdConfig = {
2022-08-11 14:47:50 -07:00
URL: terraClassicChainConfig.nodeUrl,
chainID: terraClassicChainConfig.terraChainId,
name: terraClassicChainConfig.terraName,
Modular relayer support (#1266) * Add the default backend for the relayer Start to slowly split things out. * Configure the backends when configuring the env * First stab at the pluggable listener backend * Update relayer example (and test) config * relayer: JIT backend * relayer: walletMonitor remove useless function * relayer: update worker init() funcs It is silly to accept a boolean in thing.init() vs just not running init if you don't want to run thing. * relayer: remove env property from Listener It is verified in init() in spy_listener.ts and rest_listen.ts, so it can be deferred to not require the import. * relayer: clean up the main bits Only try to init() something when it is actually supposed to run per the cli flags. * spy_relayer: more descriptive var name in main * spy_relayer: Update relay worker with more docs * spy_relayer: add targetChainName to WorkerInfo This makes it easier to pretty print the chain name in the logs without having to look the name up. * spy_relayer: update logs and use the backend * Use the Relayer interface's process() method in place of processVaa() * Update the logs to include the chain name in the worker and auditor threads * spy_relayer: remove processRequest() It has been moved to the process() method of the default Relayer backend. * spy_relayer: start fleshing out the Relayer default * spy_relayer: fix a logic bug in checkQueue() Co-authored-by: @swimricky * spy_relayer: update TokenBridgeRelayer.process() * Remove some extra logic * Actually use the ChainId type since the id of 0 is in the sdk now * spy_signature: add Relayer.runAuditor() The auditor code is payload specific and needs to be with the backend. * spy_relayer: move Relayer.runAuditor() Make it part of the backend since the backend has all of the payload specific logic into it. * spy_relayer: move relay() --> Relayer.relay() The actual relaying is part of the backend, so make it so. * spy_relayer: add Relayer.runAuditor() * spy_relayer: no more deprecated hexToNativeString * spy_relayer: implement Relayer.targetChainId() This is used for finding workable items in the incoming queue to toss into the working queue. * spy_relayer: remove relay.ts The relay() function was moved to Relayer.relay() * spy_relayer: more uses of deprecated hexToNativeString() * spy_relayer: remove unused import * spy_relayer: review feedback from @bruce-riley * Fix some spelling tyops * Simplify some logging * Simplify a conditional for the payload version check * spy_relayer: misc fixes and code clean up * Fixed integration tests * Added launch.json file for debugging in VS Code * Updated to latest wormhole SDK * Backup queue uses same key as redis * Added Terra Classic flag * Throttle potential infinite loop in audit thread * Fixed spy service connection leak Co-authored-by: Evan Gray <battledingo@gmail.com> Co-authored-by: Kevin Peters <kpeters@jumptrading.com>
2022-08-05 07:20:36 -07:00
isClassic: true,
};
const lcd = new LCDClient(lcdConfig);
const localAddresses = await calcLocalAddressesTerra(
lcd,
supportedTokens,
2022-08-11 14:47:50 -07:00
terraClassicChainConfig
);
expect(localAddresses.length).toBeGreaterThan(0);
for (const tokenAddress of localAddresses) {
const balance = await pullTerraBalance(
lcd,
2022-08-11 14:47:50 -07:00
terraClassicChainConfig.tokenBridgeAddress,
tokenAddress,
CHAIN_ID_TERRA
);
console.log(balance);
expect(balance).toBeDefined();
}
});