Skip to content

Commit 4970385

Browse files
committed
Fixing up testcases for non-eip-1559 ready platforms (#1610).
1 parent 0364dd9 commit 4970385

File tree

1 file changed

+116
-9
lines changed

1 file changed

+116
-9
lines changed

packages/tests/src.ts/test-providers.ts

Lines changed: 116 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const blockchainData: { [ network: string ]: TestCases } = {
5757
blockHash: "0x9653f180a5720f3634816eb945a6d722adee52cc47526f6357ac10adaf368135",
5858
blockNumber: 4097745,
5959
transactionIndex: 18,
60+
type: 0,
6061
from: "0x32DEF047DeFd076DB21A2D759aff2A591c972248",
6162
gasPrice: bnify("0x4a817c800"),
6263
gasLimit: bnify("0x3d090"),
@@ -76,6 +77,7 @@ const blockchainData: { [ network: string ]: TestCases } = {
7677
{
7778
blockHash: "0x36b4af7f0538559e581c8588f16477df0f676439ea67fe8d7a2ae4abb20e2566",
7879
blockNumber: 0x3c92b5,
80+
type: 0,
7981
contractAddress: null,
8082
cumulativeGasUsed: 0x1cca2e,
8183
from: "0x18C6045651826824FEBBD39d8560584078d1b247",
@@ -122,6 +124,7 @@ const blockchainData: { [ network: string ]: TestCases } = {
122124
byzantium: true,
123125
blockHash: "0x34e5a6cfbdbb84f7625df1de69d218ade4da72f4a2558064a156674e72e976c9",
124126
blockNumber: 0x444f76,
127+
type: 0,
125128
contractAddress: null,
126129
cumulativeGasUsed: 0x15bfe7,
127130
from: "0x18C6045651826824FEBBD39d8560584078d1b247",
@@ -247,7 +250,7 @@ const blockchainData: { [ network: string ]: TestCases } = {
247250
},
248251
],
249252
transactions: [
250-
// Berlin tests
253+
// Berlin tests (EIP-2930)
251254
{
252255
hash: "0x48bff7b0e603200118a672f7c622ab7d555a28f98938edb8318803eed7ea7395",
253256
type: 1,
@@ -299,12 +302,36 @@ const blockchainData: { [ network: string ]: TestCases } = {
299302
v: 0,
300303
creates: null,
301304
chainId: 3
302-
}
305+
},
306+
// London Tests (EIP-1559)
307+
{
308+
hash: '0xb8c7871d9d8597ee8a50395d8b39dafa280c90337dc501d0db1321806c6ea98c',
309+
blockHash: '0xfd824501af65b1d0f21ea9eb7ec83f45108fcd6fd1bca5d6414ba5923ad87b49',
310+
blockNumber: 10512507,
311+
transactionIndex: 5,
312+
type: 2,
313+
creates: null,
314+
from: '0xad252DD6C011E613610A36368f04aC84D5185b7c',
315+
gasPrice: bnify("0x0268ab0ed6"),
316+
maxPriorityFeePerGas: bnify("0x0268ab0ed6"),
317+
maxFeePerGas: bnify("0x0268ab0ed6"),
318+
gasLimit: bnify("0x5208"),
319+
to: '0x8210357f377E901f18E45294e86a2A32215Cc3C9',
320+
value: bnify("0x7b"),
321+
nonce: 0,
322+
data: '0x',
323+
r: '0x7426c348119eed4e9e0525b52aa77edbbf1107610702b4642fa9d2688dce6fa7',
324+
s: '0x03f606ad1f12af5876280a34601a4eb3919b797cf3878161e2d24b61d2609846',
325+
v: 1,
326+
accessList: [],
327+
chainId: 3,
328+
},
303329
],
304330
transactionReceipts: [
305331
{
306332
blockHash: "0xc9235b8253fce455942147aa8b450d23081b867ffbb2a1e4dec934827cd80f8f",
307333
blockNumber: 0x1564d8,
334+
type: 0,
308335
contractAddress: null,
309336
cumulativeGasUsed: bnify("0x80b9"),
310337
from: "0xb346D5019EeafC028CfC01A5f789399C2314ae8D",
@@ -356,6 +383,24 @@ const blockchainData: { [ network: string ]: TestCases } = {
356383
transactionHash: "0xf724f1d6813f13fb523c5f6af6261d06d41138dd094fff723e09fb0f893f03e6",
357384
transactionIndex: 0x2
358385
},
386+
// London Tests (EIP-1559)
387+
{
388+
blockNumber: 10512507,
389+
blockHash: '0xfd824501af65b1d0f21ea9eb7ec83f45108fcd6fd1bca5d6414ba5923ad87b49',
390+
transactionHash: '0xb8c7871d9d8597ee8a50395d8b39dafa280c90337dc501d0db1321806c6ea98c',
391+
transactionIndex: 5,
392+
byzantium: true,
393+
type: 2,
394+
to: '0x8210357f377E901f18E45294e86a2A32215Cc3C9',
395+
from: '0xad252DD6C011E613610A36368f04aC84D5185b7c',
396+
contractAddress: null,
397+
gasUsed: bnify("0x5208"),
398+
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
399+
logs: [],
400+
cumulativeGasUsed: bnify("0x038f3e"),
401+
effectiveGasPrice: bnify("0x268ab0ed6"),
402+
status: 1,
403+
}
359404
],
360405
},
361406
goerli: {
@@ -406,6 +451,7 @@ const blockchainData: { [ network: string ]: TestCases } = {
406451
blockHash: "0x2384e8e8bdcf6eb87ec7c138fa503ac34adb32cac817e4b35f14d4339eaa1993",
407452
blockNumber: 47464,
408453
byzantium: true,
454+
type: 0,
409455
contractAddress: null,
410456
cumulativeGasUsed: bnify(21000),
411457
from: "0x8c1e1e5b47980D214965f3bd8ea34C413E120ae4",
@@ -684,8 +730,9 @@ Object.keys(blockchainData).forEach((network) => {
684730
});
685731

686732
tests.transactions.forEach((test) => {
687-
addObjectTest(`fetches transaction ${ test.hash }`, async (provider: ethers.providers.Provider) => {
688-
const tx = await provider.getTransaction(test.hash);
733+
const hash = test.hash;
734+
addObjectTest(`fetches transaction ${ hash }`, async (provider: ethers.providers.Provider) => {
735+
const tx = await provider.getTransaction(hash);
689736

690737
// This changes with every block
691738
assert.equal(typeof(tx.confirmations), "number", "confirmations is a number");
@@ -702,13 +749,19 @@ Object.keys(blockchainData).forEach((network) => {
702749
return true;
703750
}
704751

752+
// @TODO: Remove once Etherscan supports EIP-1559
753+
if (hash === "0xb8c7871d9d8597ee8a50395d8b39dafa280c90337dc501d0db1321806c6ea98c" && provider === "EtherscanProvider") {
754+
return true;
755+
}
756+
705757
return false;
706758
});
707759
});
708760

709761
tests.transactionReceipts.forEach((test) => {
710-
addObjectTest(`fetches transaction receipt ${ test.transactionHash }`, async (provider: ethers.providers.Provider) => {
711-
const receipt = await provider.getTransactionReceipt(test.transactionHash);
762+
const hash = test.transactionHash;
763+
addObjectTest(`fetches transaction receipt ${ hash }`, async (provider: ethers.providers.Provider) => {
764+
const receipt = await provider.getTransactionReceipt(hash);
712765

713766
if (test.status === null) {
714767
assert.ok(receipt.status === undefined, "no status");
@@ -727,6 +780,11 @@ Object.keys(blockchainData).forEach((network) => {
727780
return true;
728781
}
729782

783+
// @TODO: Remove once Etherscan supports EIP-1559
784+
if (hash === "0xb8c7871d9d8597ee8a50395d8b39dafa280c90337dc501d0db1321806c6ea98c" && provider === "EtherscanProvider") {
785+
return true;
786+
}
787+
730788
return false;
731789
});
732790
});
@@ -737,6 +795,11 @@ Object.keys(blockchainData).forEach((network) => {
737795
testFunctions.push({
738796
name: `throws correct ${ code } error`,
739797
networks: [ "ropsten" ],
798+
checkSkip: (provider: string, network: string, test: TestDescription) => {
799+
// @TODO: Remove once Etherscan supports EIP-1559
800+
return (code === ethers.utils.Logger.errors.UNPREDICTABLE_GAS_LIMIT && provider === "EtherscanProvider");
801+
//return false;
802+
},
740803
execute: async (provider: ethers.providers.Provider) => {
741804
try {
742805
const value = await func(provider);
@@ -768,7 +831,7 @@ Object.keys(blockchainData).forEach((network) => {
768831
gasPrice: 9000000000,
769832
gasLimit: 21000,
770833
chainId: 3,
771-
value: 1
834+
value: 1,
772835
};
773836

774837
const wallet = ethers.Wallet.createRandom();
@@ -781,7 +844,10 @@ Object.keys(blockchainData).forEach((network) => {
781844
to: "0x8ba1f109551bD432803012645Ac136ddd64DBA72",
782845
gasPrice: 9000000000,
783846
gasLimit: 21000,
784-
value: 1
847+
value: 1,
848+
849+
// @TODO: Remove this once all providers are eip-1559 savvy
850+
type: 0,
785851
};
786852

787853
const wallet = ethers.Wallet.createRandom().connect(provider);
@@ -796,7 +862,7 @@ Object.keys(blockchainData).forEach((network) => {
796862
})();
797863

798864
testFunctions.push({
799-
name: "sends a transaction",
865+
name: "sends a legacy transaction",
800866
extras: [ "funding" ], // We need funding to the fundWallet
801867
timeout: 900, // 15 minutes
802868
networks: [ "ropsten" ], // Only test on Ropsten
@@ -816,6 +882,7 @@ testFunctions.push({
816882
assert.ok(b0.gt(ethers.constants.Zero), "balance is non-zero");
817883

818884
const tx = await wallet.sendTransaction({
885+
type: 0,
819886
to: addr,
820887
value: 123,
821888
gasPrice: gasPrice
@@ -872,6 +939,46 @@ testFunctions.push({
872939
}
873940
});
874941

942+
testFunctions.push({
943+
name: "sends an EIP-1559 transaction",
944+
extras: [ "funding" ], // We need funding to the funWallet
945+
timeout: 900, // 15 minutes
946+
networks: [ "ropsten" ], // Only test on Ropsten
947+
checkSkip: (provider: string, network: string, test: TestDescription) => {
948+
// These don't support EIP-1559 yet for sending
949+
return (provider === "AlchemyProvider" || provider === "EtherscanProvider");
950+
},
951+
execute: async (provider: ethers.providers.Provider) => {
952+
const wallet = fundWallet.connect(provider);
953+
954+
const addr = "0x8210357f377E901f18E45294e86a2A32215Cc3C9";
955+
956+
await waiter(3000);
957+
958+
const b0 = await provider.getBalance(wallet.address);
959+
assert.ok(b0.gt(ethers.constants.Zero), "balance is non-zero");
960+
961+
const tx = await wallet.sendTransaction({
962+
type: 2,
963+
accessList: {
964+
"0x8ba1f109551bD432803012645Ac136ddd64DBA72": [
965+
"0x0000000000000000000000000000000000000000000000000000000000000000",
966+
"0x0000000000000000000000000000000000000000000000000000000000000042",
967+
]
968+
},
969+
to: addr,
970+
value: 123,
971+
});
972+
973+
await tx.wait();
974+
975+
await waiter(3000);
976+
977+
const b1 = await provider.getBalance(wallet.address);
978+
assert.ok(b0.gt(b1), "balance is decreased");
979+
}
980+
});
981+
875982
describe("Test Provider Methods", function() {
876983
let fundReceipt: Promise<ethers.providers.TransactionReceipt> = null;
877984
const faucet = "0x8210357f377E901f18E45294e86a2A32215Cc3C9";

0 commit comments

Comments
 (0)