Skip to content

Commit

Permalink
fix providers type, expose test/chains.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
adraffy committed Sep 2, 2024
1 parent dca5f8e commit cd0999b
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 223 deletions.
32 changes: 32 additions & 0 deletions v2/test/chains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { CHAINS } from '../src/chains.js';
import { CHAIN_MAP, providerURL } from './providers.js';

//

const usingPublic: string[] = [];
const leftoverChains = new Set<bigint>(Object.values(CHAINS));

for (const info of CHAIN_MAP.values()) {
leftoverChains.delete(info.chain);
const url = providerURL(info.chain);
console.log(
info.chain.toString().padStart(8),
info.name.padEnd(16),
`[${info.alchemy ? 'A' : ' '}${info.infura ? 'I' : ' '}${info.ankr ? 'K' : ' '}]`,
url === info.rpc ? '!' : ' ',
url
);
if (url === info.rpc) {
usingPublic.push(info.name);
}
}

if (usingPublic.length) {
console.log(`\x1B[31mWARNING!\x1B[0m ${usingPublic.length} using public!`);
console.log(usingPublic);
}

if (leftoverChains.size) {
console.log(leftoverChains);
throw new Error('missing ChainInfo');
}
24 changes: 0 additions & 24 deletions v2/test/debug/chains.ts

This file was deleted.

11 changes: 4 additions & 7 deletions v2/test/examples/Examples.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EVMRequest } from '../../src/vm.js';
import { EthProver } from '../../src/eth/EthProver.js';
import { Foundry } from '@adraffy/blocksmith';
import { ethers } from 'ethers';
import { hexlify, toBeHex, randomBytes, concat, dataSlice } from 'ethers';
import { test, afterAll, expect } from 'bun:test';

test('ClowesConcatSlice', async () => {
Expand All @@ -13,11 +13,8 @@ test('ClowesConcatSlice', async () => {
const LAST = 5;
const VALUE = 1337;

const data = ethers.hexlify(ethers.randomBytes(SIZE));
const key = ethers.concat([
ethers.dataSlice(data, 0, FIRST),
ethers.dataSlice(data, -LAST),
]);
const data = hexlify(randomBytes(SIZE));
const key = concat([dataSlice(data, 0, FIRST), dataSlice(data, -LAST)]);

const contract = await foundry.deploy({
sol: `
Expand Down Expand Up @@ -54,7 +51,7 @@ test('ClowesConcatSlice', async () => {

expect(values).toHaveLength(2);
expect(values[0]).toStrictEqual(data);
expect(values[1]).toStrictEqual(ethers.toBeHex(VALUE, 32));
expect(values[1]).toStrictEqual(toBeHex(VALUE, 32));
});

test('FOLLOW === PUSH_SLOT CONCAT KECCAK SLOT_ZERO SLOT_ADD', async () => {
Expand Down
Loading

0 comments on commit cd0999b

Please sign in to comment.