Skip to content

Commit

Permalink
tests: migrated all goerli tests to sepolia; contracts and config
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Apr 17, 2024
1 parent 8220090 commit 631aa1d
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src.ts/_tests/create-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface ProviderCreator {
create: (network: string) => null | AbstractProvider;
};

const ethNetworks = [ "default", "mainnet", "goerli" ];
const ethNetworks = [ "default", "mainnet", "sepolia" ];
//const maticNetworks = [ "matic", "maticmum" ];

const ProviderCreators: Array<ProviderCreator> = [
Expand Down
19 changes: 12 additions & 7 deletions src.ts/_tests/test-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import type { ContractEventPayload, ContractEventName, Log } from "../index.js";
setupProviders();

describe("Test Contract", function() {
const addr = "0x99417252Aad7B065940eBdF50d665Fb8879c5958";
const addr = "0x24264C81146c23bbF83Db1d3F87d2111C2935Ffa";
const networkName = "sepolia";

const abi = [
"error CustomError1(uint256 code, string message)",

Expand All @@ -30,7 +32,7 @@ describe("Test Contract", function() {
it("tests contract calls", async function() {
this.timeout(10000);

const provider = getProvider("InfuraProvider", "goerli");
const provider = getProvider("InfuraProvider", networkName);
const contract = new Contract(addr, abi, provider);

assert.equal(await contract.testCallAdd(4, 5), BigInt(9), "testCallAdd(4, 5)");
Expand All @@ -40,7 +42,7 @@ describe("Test Contract", function() {
it("tests events", async function() {
this.timeout(60000);

const provider = getProvider("InfuraProvider", "goerli");
const provider = getProvider("InfuraProvider", networkName);
assert.ok(provider);

const contract = new Contract(addr, abi, provider);
Expand All @@ -49,7 +51,7 @@ describe("Test Contract", function() {
const contractSigner = <any>contract.connect(signer);

const vUint256 = 42;
const vAddrName = "ethers.eth";
const vAddrName = "tests.eth";
const vAddr = "0x228568EA92aC5Bc281c1E30b1893735c60a139F1";
const vString = "Hello";
const vBytes = "0x12345678";
Expand Down Expand Up @@ -260,8 +262,10 @@ describe("Test Typed Contract Interaction", function() {
abi.push(`function testTyped(bytes memory) public pure returns (string memory)`);
abi.push(`function testTyped(string memory) public pure returns (string memory)`);

const addr = "0x838f41545DA5e18AA0e1ab391085d22E172B7B02";
const provider = getProvider("InfuraProvider", "goerli");
const addr = "0xf20ba47c47a32fc2d9ad846ff06f2fa6e89eec74";
const networkName = "sepolia";

const provider = getProvider("InfuraProvider", networkName);
const contract = new Contract(addr, abi, provider);

for (const { types, valueFunc } of tests) {
Expand Down Expand Up @@ -446,7 +450,8 @@ describe("Test Contract Fallback", function() {
},
];

const provider = getProvider("InfuraProvider", "goerli");
const networkName = "sepolia";
const provider = getProvider("InfuraProvider", networkName);

const testGroups: Array<{ group: "sendNone" | "sendData" | "sendValue" | "sendDataAndValue", tx: any }> = [
{
Expand Down
8 changes: 4 additions & 4 deletions src.ts/_tests/test-providers-avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ setupProviders();

describe("Resolve ENS avatar", function() {
[
{ title: "data", name: "data-avatar.tests.ethers.eth", value: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAMAAACeL25MAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyVpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDYuMC1jMDAyIDc5LjE2NDQ4OCwgMjAyMC8wNy8xMC0yMjowNjo1MyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIyLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NUQ4NTEyNUIyOEIwMTFFQzg0NTBDNTU2RDk1NTA5NzgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NUQ4NTEyNUMyOEIwMTFFQzg0NTBDNTU2RDk1NTA5NzgiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo1RDg1MTI1OTI4QjAxMUVDODQ1MEM1NTZEOTU1MDk3OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo1RDg1MTI1QTI4QjAxMUVDODQ1MEM1NTZEOTU1MDk3OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkbM0uMAAAAGUExURQAA/wAAAHtivz4AAAAOSURBVHjaYmDABAABBgAAFAABaEkyYwAAAABJRU5ErkJggg==" },
{ title: "ipfs", name: "ipfs-avatar.tests.ethers.eth", value: "https:/\/gateway.ipfs.io/ipfs/QmQsQgpda6JAYkFoeVcj5iPbwV3xRcvaiXv3bhp1VuYUqw" },
{ title: "url", name: "url-avatar.tests.ethers.eth", value: "https:/\/ethers.org/static/logo.png" },
{ title: "data", name: "data-avatar.tests.eth", value: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAMAAACeL25MAAAAGXRFWHRTb2Z0d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jcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkbM0uMAAAAGUExURQAA/wAAAHtivz4AAAAOSURBVHjaYmDABAABBgAAFAABaEkyYwAAAABJRU5ErkJggg==" },
{ title: "ipfs", name: "ipfs-avatar.tests.eth", value: "https:/\/gateway.ipfs.io/ipfs/QmQsQgpda6JAYkFoeVcj5iPbwV3xRcvaiXv3bhp1VuYUqw" },
{ title: "url", name: "url-avatar.tests.eth", value: "https:/\/ethers.org/static/logo.png" },
].forEach((test) => {
it(`Resolves avatar for ${ test.title }`, async function() {
this.timeout(60000);
const provider = connect("goerli");
const provider = connect("sepolia");
const avatar = await provider.getAvatar(test.name);
assert.equal(test.value, avatar, "avatar url");
});
Expand Down
33 changes: 22 additions & 11 deletions src.ts/_tests/test-providers-ccip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ describe("Test CCIP execution", function() {
assert.equal(result, keccak256(check), "response is equal");
}

const address = "0x6C5ed35574a9b4d163f75bBf0595F7540D8FCc2d";
const address = "0xaeaa06a37e6421ac63120d6daddee0ffa04b43e8";
const networkName = "sepolia";

const calldata = "0x1234";

it("testGet passes under normal operation", async function() {
this.timeout(60000);

const provider = connect("goerli");
const provider = connect(networkName);

// testGet(bytes callData = "0x1234")
const tx = {
Expand All @@ -44,7 +46,7 @@ describe("Test CCIP execution", function() {
it("testGet should fail with CCIP not explicitly enabled by overrides", async function() {
this.timeout(60000);

const provider = connect("goerli");
const provider = connect(networkName);

// testGet(bytes callData = "0x1234")
const tx = {
Expand All @@ -56,15 +58,19 @@ describe("Test CCIP execution", function() {
const result = await provider.call(tx);
console.log(result);
}, (error: unknown) => {
const offchainErrorData = "0x556f18300000000000000000000000006c5ed35574a9b4d163f75bbf0595f7540d8fcc2d00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000";
const offchainErrorData = concat([
"0x556f1830000000000000000000000000",
address,
"0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000"
]);
return (isCallException(error) && error.data === offchainErrorData);
});
});

it("testGet should fail with CCIP explicitly disabled on provider", async function() {
this.timeout(60000);

const provider = connect("goerli");
const provider = connect(networkName);
provider.disableCcipRead = true;

// testGetFail(bytes callData = "0x1234")
Expand All @@ -77,15 +83,20 @@ describe("Test CCIP execution", function() {
const result = await provider.call(tx);
console.log(result);
}, (error: unknown) => {
const offchainErrorData = "0x556f18300000000000000000000000006c5ed35574a9b4d163f75bbf0595f7540d8fcc2d00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000";
const offchainErrorData = concat([
"0x556f1830000000000000000000000000",
address,
"0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000"
]);

return (isCallException(error) && error.data === offchainErrorData);
});
});

it("testGetFail should fail if all URLs 5xx", async function() {
this.timeout(60000);

const provider = connect("goerli");
const provider = connect(networkName);

// testGetFail(bytes callData = "0x1234")
const tx = {
Expand All @@ -106,7 +117,7 @@ describe("Test CCIP execution", function() {
it("testGetSenderFail should fail if sender does not match", async function() {
this.timeout(60000);

const provider = connect("goerli");
const provider = connect(networkName);

// testGetSenderFail(bytes callData = "0x1234")
const tx = {
Expand All @@ -131,7 +142,7 @@ describe("Test CCIP execution", function() {
it("testGetMissing should fail if early URL 4xx", async function() {
this.timeout(60000);

const provider = connect("goerli");
const provider = connect(networkName);

// testGetMissing(bytes callData = "0x1234")
const tx = {
Expand All @@ -153,7 +164,7 @@ describe("Test CCIP execution", function() {
it("testGetFallback passes if any URL returns correctly", async function() {
this.timeout(60000);

const provider = connect("goerli");
const provider = connect(networkName);

// testGetFallback(bytes callData = "0x1234")
const tx = {
Expand All @@ -168,7 +179,7 @@ describe("Test CCIP execution", function() {
it("testPost passes under normal operation", async function() {
this.timeout(60000);

const provider = connect("goerli");
const provider = connect(networkName);

// testPost(bytes callData = "0x1234")
const tx = {
Expand Down
12 changes: 6 additions & 6 deletions src.ts/_tests/test-providers-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ describe("Test Provider Transaction operations", function() {

describe("Test Networks", function() {
const networks = [
"mainnet", "goerli", "sepolia", "holesky",
"arbitrum", "arbitrum-goerli", "arbitrum-sepolia",
"base", "base-goerli", "base-sepolia",
"mainnet", "sepolia", "holesky",
"arbitrum", "arbitrum-sepolia",
"base", "base-sepolia",
"bnb", "bnbt",
"linea", "linea-goerli",
"matic", "matic-mumbai",
"optimism", "optimism-goerli", "optimism-sepolia",
"linea", "linea-sepolia",
"matic", "matic-mumbai", "matic-amoy",
"optimism", "optimism-sepolia",
"xdai",
];

Expand Down
6 changes: 3 additions & 3 deletions src.ts/_tests/test-providers-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ describe("Tests Provider Call Exception", function() {
//{ code: 0x51, reason: "UNINITIALIZED_FUNCTION_CALL" },
];

const testAddr = "0xF20Ba47c47a32fc2d9ad846fF06f2fa6e89eeC74";
const testAddr = "0x86d19fF4b2EB0D451511B5B930b01DC71fD9a2Ee";
const networkName = "sepolia";

const networkName = "goerli";
for (const { code, reason } of panics) {
for (const method of [ "call", "estimateGas" ]) {
for (const providerName of providerNames) {
Expand Down Expand Up @@ -166,7 +166,7 @@ describe("Tests Provider Call Exception", function() {
describe("Test Provider Blockchain Errors", function() {
const wallet = new Wallet(<string>(process.env.FAUCET_PRIVATEKEY));

const networkName = "goerli";
const networkName = "sepolia";
for (const providerName of providerNames) {

const provider = getProvider(providerName, networkName);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/_tests/test-providers-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("Sends Transactions", function() {
const wallet = new Wallet(<string>(process.env.FAUCET_PRIVATEKEY));
console.log("Faucet Address:", wallet.address);

const networkName = "goerli";
const networkName = "sepolia";
for (const providerName of providerNames) {
const provider = getProvider(providerName, networkName);
if (provider == null) { continue; }
Expand Down
6 changes: 3 additions & 3 deletions src.ts/_tests/test-providers-wildcard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import { connect, setupProviders } from "./create-provider.js";
setupProviders();

describe("Test EIP-2544 ENS wildcards", function() {
const provider = connect("goerli");
const provider = connect("sepolia");

it("Resolves recursively", async function() {
this.timeout(10000);

const resolver = await provider.getResolver("ricmoose.hatch.eth");
assert.ok(resolver, "failed to get resolver");

assert.equal(resolver.address, "0x15abA1fa74Bfdecd63A71218DC632d4328Db8168", "address");
assert.equal(resolver.address, "0x657D81B1E647A56457ff035Af22898411673f7FD", "address");
assert.equal(await resolver.supportsWildcard(), true, "supportsWildcard()");

// Test pass-through avatar
assert.equal(await resolver.getAvatar(), "https:/\/static.ricmoo.com/uploads/profile-06cb9c3031c9.jpg", "getAvatar()");

assert.equal(await resolver.getAddress(), "0x4B711A377B1b3534749FBe5e59Bcf7F94d92EA98", "getAddress()");
assert.equal(await resolver.getAddress(), "0xF0d6e3fC0f5A23aAAA4933700438b6313Dd331bD", "getAddress()");
});
});

Expand Down

0 comments on commit 631aa1d

Please sign in to comment.