Skip to content

Commit fdce6b3

Browse files
aldousalvarezpetermetz
authored andcommitted
ci(connector-xdai): fix docker rate limit issues with openethereum image pull
Primary Changes ---------------- 1. Migrated all the xdai connector tests to besu ledger images that is being pulled from ghcr Fixes #3413 Signed-off-by: aldousalvarez <[email protected]>
1 parent ae3c0ff commit fdce6b3

File tree

4 files changed

+77
-64
lines changed

4 files changed

+77
-64
lines changed

packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/deploy-contract-from-json-xdai-json-object.test.ts

+18-15
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import {
1111
} from "../../../main/typescript/public-api";
1212
import {
1313
Containers,
14-
K_DEV_WHALE_ACCOUNT_PRIVATE_KEY,
15-
K_DEV_WHALE_ACCOUNT_PUBLIC_KEY,
16-
OpenEthereumTestLedger,
14+
BesuTestLedger,
1715
pruneDockerAllIfGithubAction,
1816
} from "@hyperledger/cactus-test-tooling";
1917
import {
@@ -45,8 +43,16 @@ test(testCase, async (t: Test) => {
4543
await Containers.logDiagnostics({ logLevel });
4644
});
4745

48-
const ledger = new OpenEthereumTestLedger({ logLevel });
49-
46+
const ledger = new BesuTestLedger({ logLevel });
47+
const containerImageVersion = "2021-08-24--feat-1244";
48+
const containerImageName =
49+
"ghcr.io/hyperledger/cactus-besu-21-1-6-all-in-one";
50+
const besuOptions = { containerImageName, containerImageVersion };
51+
const besuTestLedger = new BesuTestLedger(besuOptions);
52+
const besuKeyPair = {
53+
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
54+
};
55+
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
5056
test.onFinish(async () => {
5157
await ledger.stop();
5258
await ledger.destroy();
@@ -56,9 +62,6 @@ test(testCase, async (t: Test) => {
5662

5763
const rpcApiHttpHost = await ledger.getRpcApiHttpHost();
5864

59-
const whalePubKey = K_DEV_WHALE_ACCOUNT_PUBLIC_KEY;
60-
const whalePrivKey = K_DEV_WHALE_ACCOUNT_PRIVATE_KEY;
61-
6265
const web3 = new Web3(rpcApiHttpHost);
6366
const testEthAccount = web3.eth.accounts.create(uuidv4());
6467

@@ -92,12 +95,12 @@ test(testCase, async (t: Test) => {
9295

9396
await connector.transact({
9497
web3SigningCredential: {
95-
ethAccount: whalePubKey,
96-
secret: whalePrivKey,
98+
ethAccount: firstHighNetWorthAccount,
99+
secret: besuKeyPair.privateKey,
97100
type: Web3SigningCredentialType.PrivateKeyHex,
98101
},
99102
transactionConfig: {
100-
from: whalePubKey,
103+
from: firstHighNetWorthAccount,
101104
to: testEthAccount.address,
102105
value: 10e9,
103106
gas: 1000000,
@@ -118,8 +121,8 @@ test(testCase, async (t: Test) => {
118121
test("deploys contract via .json file", async (t2: Test) => {
119122
const deployOut = await connector.deployContractJsonObject({
120123
web3SigningCredential: {
121-
ethAccount: whalePubKey,
122-
secret: whalePrivKey,
124+
ethAccount: firstHighNetWorthAccount,
125+
secret: besuKeyPair.privateKey,
123126
type: Web3SigningCredentialType.PrivateKeyHex,
124127
},
125128
gas: 1000000,
@@ -147,8 +150,8 @@ test(testCase, async (t: Test) => {
147150
methodName: "sayHello",
148151
params: [],
149152
web3SigningCredential: {
150-
ethAccount: whalePubKey,
151-
secret: whalePrivKey,
153+
ethAccount: firstHighNetWorthAccount,
154+
secret: besuKeyPair.privateKey,
152155
type: Web3SigningCredentialType.PrivateKeyHex,
153156
},
154157
gas: 1000000,

packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/deploy-contract-from-json-xdai.test.ts

+19-13
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import {
1414
} from "../../../main/typescript/public-api";
1515
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
1616
import {
17-
K_DEV_WHALE_ACCOUNT_PRIVATE_KEY,
18-
K_DEV_WHALE_ACCOUNT_PUBLIC_KEY,
19-
OpenEthereumTestLedger,
17+
BesuTestLedger,
2018
pruneDockerAllIfGithubAction,
2119
} from "@hyperledger/cactus-test-tooling";
2220
import {
@@ -36,11 +34,17 @@ import { K_CACTUS_XDAI_TOTAL_TX_COUNT } from "../../../main/typescript/prometheu
3634
const testCase = "deploys contract via .json file";
3735
describe(testCase, () => {
3836
const logLevel: LogLevelDesc = "TRACE";
39-
const ledger = new OpenEthereumTestLedger({ logLevel });
37+
const ledger = new BesuTestLedger({ logLevel });
38+
const containerImageVersion = "2021-08-24--feat-1244";
39+
const containerImageName =
40+
"ghcr.io/hyperledger/cactus-besu-21-1-6-all-in-one";
41+
const besuOptions = { containerImageName, containerImageVersion };
42+
const besuTestLedger = new BesuTestLedger(besuOptions);
43+
const besuKeyPair = {
44+
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
45+
};
4046
const contractName = "HelloWorld";
4147
const expressApp = express();
42-
const whalePubKey = K_DEV_WHALE_ACCOUNT_PUBLIC_KEY;
43-
const whalePrivKey = K_DEV_WHALE_ACCOUNT_PRIVATE_KEY;
4448
expressApp.use(bodyParser.json({ limit: "250mb" }));
4549
const server = http.createServer(expressApp);
4650
let addressInfo,
@@ -52,6 +56,7 @@ describe(testCase, () => {
5256
apiHost: string,
5357
web3: Web3,
5458
factory: PluginFactoryLedgerConnector,
59+
firstHighNetWorthAccount: string,
5560
testEthAccount: Account,
5661
keychainEntryKey: string,
5762
keychainEntryValue: string,
@@ -60,6 +65,7 @@ describe(testCase, () => {
6065
apiClient: XdaiApi;
6166

6267
beforeAll(async () => {
68+
firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
6369
const pruning = pruneDockerAllIfGithubAction({ logLevel });
6470
await expect(pruning).resolves.toBeTruthy();
6571
});
@@ -125,12 +131,12 @@ describe(testCase, () => {
125131

126132
await connector.transact({
127133
web3SigningCredential: {
128-
ethAccount: whalePubKey,
129-
secret: whalePrivKey,
134+
ethAccount: firstHighNetWorthAccount,
135+
secret: besuKeyPair.privateKey,
130136
type: Web3SigningCredentialType.PrivateKeyHex,
131137
},
132138
transactionConfig: {
133-
from: whalePubKey,
139+
from: firstHighNetWorthAccount,
134140
to: testEthAccount.address,
135141
value: 10e9,
136142
gas: 1000000,
@@ -154,8 +160,8 @@ describe(testCase, () => {
154160
// contractAbi: HelloWorldContractJson.abi,
155161
constructorArgs: [],
156162
web3SigningCredential: {
157-
ethAccount: whalePubKey,
158-
secret: whalePrivKey,
163+
ethAccount: firstHighNetWorthAccount,
164+
secret: besuKeyPair.privateKey,
159165
type: Web3SigningCredentialType.PrivateKeyHex,
160166
},
161167
gas: 1000000,
@@ -174,8 +180,8 @@ describe(testCase, () => {
174180
methodName: "sayHello",
175181
params: [],
176182
web3SigningCredential: {
177-
ethAccount: whalePubKey,
178-
secret: whalePrivKey,
183+
ethAccount: firstHighNetWorthAccount,
184+
secret: besuKeyPair.privateKey,
179185
type: Web3SigningCredentialType.PrivateKeyHex,
180186
},
181187
});

packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai-json-object.test.ts

+18-16
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,24 @@ import {
99
ReceiptType,
1010
} from "../../../main/typescript/public-api";
1111
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
12-
import {
13-
K_DEV_WHALE_ACCOUNT_PRIVATE_KEY,
14-
K_DEV_WHALE_ACCOUNT_PUBLIC_KEY,
15-
OpenEthereumTestLedger,
16-
} from "@hyperledger/cactus-test-tooling";
12+
import { BesuTestLedger } from "@hyperledger/cactus-test-tooling";
1713
import { LogLevelDesc } from "@hyperledger/cactus-common";
1814
import HelloWorldContractJson from "../../solidity/hello-world-contract/HelloWorld.json";
1915
import Web3 from "web3";
2016
import { PluginImportType } from "@hyperledger/cactus-core-api";
2117

2218
test("deploys contract via .json file", async (t: Test) => {
2319
const logLevel: LogLevelDesc = "TRACE";
24-
const xdaiTestLedger = new OpenEthereumTestLedger({});
20+
const xdaiTestLedger = new BesuTestLedger({});
21+
const containerImageVersion = "2021-08-24--feat-1244";
22+
const containerImageName =
23+
"ghcr.io/hyperledger/cactus-besu-21-1-6-all-in-one";
24+
const besuOptions = { containerImageName, containerImageVersion };
25+
const besuTestLedger = new BesuTestLedger(besuOptions);
26+
const besuKeyPair = {
27+
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
28+
};
29+
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
2530
await xdaiTestLedger.start();
2631

2732
test.onFinish(async () => {
@@ -31,9 +36,6 @@ test("deploys contract via .json file", async (t: Test) => {
3136

3237
const rpcApiHttpHost = await xdaiTestLedger.getRpcApiHttpHost();
3338

34-
const whalePubKey = K_DEV_WHALE_ACCOUNT_PUBLIC_KEY;
35-
const whalePrivKey = K_DEV_WHALE_ACCOUNT_PRIVATE_KEY;
36-
3739
const web3 = new Web3(rpcApiHttpHost);
3840
const testEthAccount = web3.eth.accounts.create(uuidv4());
3941

@@ -63,16 +65,16 @@ test("deploys contract via .json file", async (t: Test) => {
6365

6466
await connector.transact({
6567
web3SigningCredential: {
66-
ethAccount: whalePubKey,
67-
secret: whalePrivKey,
68+
ethAccount: firstHighNetWorthAccount,
69+
secret: besuKeyPair.privateKey,
6870
type: Web3SigningCredentialType.PrivateKeyHex,
6971
},
7072
consistencyStrategy: {
7173
blockConfirmations: 0,
7274
receiptType: ReceiptType.NodeTxPoolAck,
7375
},
7476
transactionConfig: {
75-
from: whalePubKey,
77+
from: firstHighNetWorthAccount,
7678
to: testEthAccount.address,
7779
value: 10e9,
7880
gas: 1000000,
@@ -89,8 +91,8 @@ test("deploys contract via .json file", async (t: Test) => {
8991
const deployOut = await connector.deployContractJsonObject({
9092
constructorArgs: [],
9193
web3SigningCredential: {
92-
ethAccount: whalePubKey,
93-
secret: whalePrivKey,
94+
ethAccount: firstHighNetWorthAccount,
95+
secret: besuKeyPair.privateKey,
9496
type: Web3SigningCredentialType.PrivateKeyHex,
9597
},
9698
gas: 1000000,
@@ -118,8 +120,8 @@ test("deploys contract via .json file", async (t: Test) => {
118120
methodName: "sayHello",
119121
params: [],
120122
web3SigningCredential: {
121-
ethAccount: whalePubKey,
122-
secret: whalePrivKey,
123+
ethAccount: firstHighNetWorthAccount,
124+
secret: besuKeyPair.privateKey,
123125
type: Web3SigningCredentialType.PrivateKeyHex,
124126
},
125127
contractJSON: HelloWorldContractJson,

packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai.test.ts

+22-20
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,27 @@ import {
1111
ReceiptType,
1212
} from "../../../main/typescript/public-api";
1313
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
14-
import {
15-
K_DEV_WHALE_ACCOUNT_PRIVATE_KEY,
16-
K_DEV_WHALE_ACCOUNT_PUBLIC_KEY,
17-
OpenEthereumTestLedger,
18-
} from "@hyperledger/cactus-test-tooling";
14+
import { BesuTestLedger } from "@hyperledger/cactus-test-tooling";
1915
import { LogLevelDesc } from "@hyperledger/cactus-common";
2016
import HelloWorldContractJson from "../../solidity/hello-world-contract/HelloWorld.json";
2117
import Web3 from "web3";
2218
import { PluginImportType } from "@hyperledger/cactus-core-api";
2319

2420
const logLevel: LogLevelDesc = "TRACE";
25-
let xdaiTestLedger: OpenEthereumTestLedger;
21+
let xdaiTestLedger: BesuTestLedger;
2622
const testCase = "Xdai Ledger Connector Plugin";
2723
describe(testCase, () => {
24+
const containerImageVersion = "2021-08-24--feat-1244";
25+
const containerImageName =
26+
"ghcr.io/hyperledger/cactus-besu-21-1-6-all-in-one";
27+
const besuOptions = { containerImageName, containerImageVersion };
28+
const besuTestLedger = new BesuTestLedger(besuOptions);
29+
const besuKeyPair = {
30+
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
31+
};
32+
let firstHighNetWorthAccount: string;
2833
let contractAddress: string;
2934
const contractName = "HelloWorld";
30-
const whalePubKey = K_DEV_WHALE_ACCOUNT_PUBLIC_KEY;
31-
const whalePrivKey = K_DEV_WHALE_ACCOUNT_PRIVATE_KEY;
3235
let keychainPlugin: PluginKeychainMemory;
3336
let connector: PluginLedgerConnectorXdai;
3437
let web3: Web3;
@@ -37,7 +40,7 @@ describe(testCase, () => {
3740
let keychainEntryValue: string, rpcApiHttpHost: string;
3841

3942
beforeAll(async () => {
40-
xdaiTestLedger = new OpenEthereumTestLedger({});
43+
xdaiTestLedger = new BesuTestLedger({});
4144
});
4245

4346
afterAll(async () => {
@@ -46,6 +49,7 @@ describe(testCase, () => {
4649
});
4750
beforeAll(async () => {
4851
await xdaiTestLedger.start();
52+
firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
4953
rpcApiHttpHost = await xdaiTestLedger.getRpcApiHttpHost();
5054
expect(rpcApiHttpHost).toBeString();
5155

@@ -82,16 +86,16 @@ describe(testCase, () => {
8286

8387
await connector.transact({
8488
web3SigningCredential: {
85-
ethAccount: whalePubKey,
86-
secret: whalePrivKey,
89+
ethAccount: firstHighNetWorthAccount,
90+
secret: besuKeyPair.privateKey,
8791
type: Web3SigningCredentialType.PrivateKeyHex,
8892
},
8993
consistencyStrategy: {
9094
blockConfirmations: 0,
9195
receiptType: ReceiptType.NodeTxPoolAck,
9296
},
9397
transactionConfig: {
94-
from: whalePubKey,
98+
from: firstHighNetWorthAccount,
9599
to: testEthAccount.address,
96100
value: 10e9,
97101
gas: 1000000,
@@ -110,8 +114,8 @@ describe(testCase, () => {
110114
// contractAbi: HelloWorldContractJson.abi,
111115
constructorArgs: [],
112116
web3SigningCredential: {
113-
ethAccount: whalePubKey,
114-
secret: whalePrivKey,
117+
ethAccount: firstHighNetWorthAccount,
118+
secret: besuKeyPair.privateKey,
115119
type: Web3SigningCredentialType.PrivateKeyHex,
116120
},
117121
// bytecode: HelloWorldContractJson.bytecode,
@@ -131,8 +135,8 @@ describe(testCase, () => {
131135
methodName: "sayHello",
132136
params: [],
133137
web3SigningCredential: {
134-
ethAccount: whalePubKey,
135-
secret: whalePrivKey,
138+
ethAccount: firstHighNetWorthAccount,
139+
secret: besuKeyPair.privateKey,
136140
type: Web3SigningCredentialType.PrivateKeyHex,
137141
},
138142
});
@@ -205,7 +209,7 @@ describe(testCase, () => {
205209
});
206210
fail("invalid nonce should have thrown");
207211
} catch (error: any) {
208-
expect(error.message).toContain("Transaction nonce is too low.");
212+
expect(error.message).toContain("Nonce too low");
209213
}
210214
const { callOutput: getNameOut } = await connector.invokeContract({
211215
contractName,
@@ -303,9 +307,7 @@ describe(testCase, () => {
303307
});
304308
fail("invalid nonce should have thrown");
305309
} catch (error: any) {
306-
expect(error.message).toContain(
307-
"Transaction with the same hash was already imported",
308-
);
310+
expect(error.message).toContain("Nonce too low");
309311
}
310312
const { callOutput: getNameOut } = await connector.invokeContract({
311313
contractName,

0 commit comments

Comments
 (0)