Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xverin committed Jun 21, 2024
1 parent 7a5e6f9 commit 4409784
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions contracts/token_holding_amount/NoderealClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pragma solidity ^0.8.8;

import "../libraries/Http.sol";
import "../libraries/Utils.sol";

library NoderealClient {
function getTokenBalance(
string memory url,
Expand Down
1 change: 0 additions & 1 deletion contracts/token_holding_amount/TokenHoldingAmount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import "../libraries/AssertionLogic.sol";
import "../libraries/Identities.sol";
import "../DynamicAssertion.sol";
import "./Constants.sol";

abstract contract TokenHoldingAmount is DynamicAssertion {
mapping(string => string) internal tokenNames;
mapping(string => uint256[]) internal tokenRanges;
Expand Down
4 changes: 2 additions & 2 deletions contracts/token_holding_amount/TokenMapping.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

pragma solidity ^0.8.8;

import { TokenLogic } from "./TokenLogic.sol";
import { TokenQueryLogic } from "./TokenQueryLogic.sol";
import "../libraries/Identities.sol";

// brc20
Expand Down Expand Up @@ -70,7 +70,7 @@ import { Usdt } from "./erc20/Usdt.sol";
import { Wbtc } from "./erc20//Wbtc.sol";
import { Cvx } from "./erc20/Cvx.sol";
import { Usdd } from "./erc20/Usdd.sol";
contract TokenMapping is TokenLogic {
contract TokenMapping is TokenQueryLogic {
constructor() {
// btcs
tokenNames["btcs"] = Btcs.getTokenName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import "../libraries/Utils.sol";
import { TokenHoldingAmount } from "./TokenHoldingAmount.sol";
import { NoderealClient } from "./NoderealClient.sol";
import { GeniidataClient } from "./GeniidataClient.sol";
abstract contract TokenLogic is TokenHoldingAmount {

abstract contract TokenQueryLogic is TokenHoldingAmount {
mapping(uint32 => string) internal networkUrls;
mapping(uint32 => bool) private queriedNetworks;
mapping(string => mapping(uint32 => string)) tokenAddresses;
Expand All @@ -32,10 +33,10 @@ abstract contract TokenLogic is TokenHoldingAmount {
mapping(string => uint32[]) internal tokenNetworks;

constructor() {
networkUrls[Web3Networks.Bsc] = "https://bsc-mainnet.nodereal.io/v1/"; // test against mock server => "http://localhost:19527/nodereal_jsonrpc/"
networkUrls[Web3Networks.Bsc] = "https://bsc-mainnet.nodereal.io/v1/"; // test against mock server => "http://localhost:19530/nodereal_jsonrpc/"
networkUrls[
Web3Networks.Ethereum
] = "https://eth-mainnet.nodereal.io/v1/"; // test against mock server => "hhttp://localhost:19527/nodereal_jsonrpc/"
] = "https://eth-mainnet.nodereal.io/v1/"; // test against mock server => "http://localhost:19530/nodereal_jsonrpc/"

networkUrls[
Web3Networks.BitcoinP2tr
Expand Down
30 changes: 20 additions & 10 deletions test/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import { ethers } from "hardhat"
import { ethers, network } from "hardhat"
import { expect } from "chai"
// todo: add more tests
describe("contracts", () => {
it("should return the bytecode of the contracts", async () => {
const A1Contract = await ethers.getContractFactory("A1")
const A6Contract = await ethers.getContractFactory("A6")
const A20Contract = await ethers.getContractFactory("A20")
const TokenMapping = await ethers.getContractFactory("TokenMapping")
const tokenMapping = await TokenMapping.deploy()

expect(A1Contract.bytecode).to.be.ok
expect(A6Contract.bytecode).to.be.ok
expect(A20Contract.bytecode).to.be.ok
console.log("A1 bytecodeπŸš€πŸš€πŸš€πŸš€πŸš€πŸš€:", A1Contract.bytecode)
console.log("A6 bytecodeπŸš€πŸš€πŸš€πŸš€πŸš€:", A6Contract.bytecode)
console.log("A20 bytecodeπŸš€πŸš€πŸš€πŸš€πŸš€:", A20Contract.bytecode)
const identities = [
{
identity_type: 4,
value: "0xf7764F15Fd4F695fAD8dDd3e84F5293E6866FEFE",
networks: [7, 8],
},
]

const secrets = [
"0x23875d191b5cf587d54763ec32be12e64fdb2fe286ae32bd593d461c1d97a5389a1eae28845e3771ba49ed80e20aa4698f7c096156f91d2356f399e0a2e8789f63046fde437cb0ac9ba83e0dd6c1cb676d8411b94e91457870e37d4c8ca627ff04eb7daa1269044c64347bcf2d4619f27affb99fbd74d48fd31a7b4098655312fd69f1473fe3252a07f7080a0c41b5907e008d1456b2fcd73ce61273f131cd0ca5d632ea66c0bb4e8b6518d7cd3aea6300ab2ab995eccaafe73014302e848e023785463d2e5beb9050070f08213606166da439f5f5727b78ab557b41a3863512d23cf216e69d0e48a104354f4641150f84af53a6195a9c5439b7b40786876726a7972d74254b7160d2e484cb5f682eb74e83e94cf4500207bc256b99e5b7f916e0199d522e5ed8802760630e77d60dc7fa543beaffcd92623799ca5eecd7a7a0dde76e781a4ec76dea878fb0e3b67d192d0296ef7841abec0feefa5b5f3cfd73aa9759a1d2dc57b38f9c84ff590a9ecc48dbdb810d697fec159e0d1e124d6151",
]

const params =
"0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036574630000000000000000000000000000000000000000000000000000000000"
const tx = await tokenMapping.execute(identities, secrets, params)

await tx.wait()
})
})

0 comments on commit 4409784

Please sign in to comment.