Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(connector-xdai): fix docker rate limit issues with openethereum im… #11

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import {
} from "../../../main/typescript/public-api";
import {
Containers,
K_DEV_WHALE_ACCOUNT_PRIVATE_KEY,
K_DEV_WHALE_ACCOUNT_PUBLIC_KEY,
OpenEthereumTestLedger,
BesuTestLedger,
pruneDockerAllIfGithubAction,
} from "@hyperledger/cactus-test-tooling";
import {
Expand Down Expand Up @@ -45,8 +43,16 @@ test(testCase, async (t: Test) => {
await Containers.logDiagnostics({ logLevel });
});

const ledger = new OpenEthereumTestLedger({ logLevel });

const ledger = new BesuTestLedger({ logLevel });
const containerImageVersion = "2021-08-24--feat-1244";
const containerImageName =
"ghcr.io/hyperledger/cactus-besu-21-1-6-all-in-one";
const besuOptions = { containerImageName, containerImageVersion };
const besuTestLedger = new BesuTestLedger(besuOptions);
const besuKeyPair = {
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
};
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
test.onFinish(async () => {
await ledger.stop();
await ledger.destroy();
Expand All @@ -56,9 +62,6 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await ledger.getRpcApiHttpHost();

const whalePubKey = K_DEV_WHALE_ACCOUNT_PUBLIC_KEY;
const whalePrivKey = K_DEV_WHALE_ACCOUNT_PRIVATE_KEY;

const web3 = new Web3(rpcApiHttpHost);
const testEthAccount = web3.eth.accounts.create(uuidv4());

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

await connector.transact({
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
transactionConfig: {
from: whalePubKey,
from: firstHighNetWorthAccount,
to: testEthAccount.address,
value: 10e9,
gas: 1000000,
Expand All @@ -118,8 +121,8 @@ test(testCase, async (t: Test) => {
test("deploys contract via .json file", async (t2: Test) => {
const deployOut = await connector.deployContractJsonObject({
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
gas: 1000000,
Expand Down Expand Up @@ -147,8 +150,8 @@ test(testCase, async (t: Test) => {
methodName: "sayHello",
params: [],
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
gas: 1000000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import {
} from "../../../main/typescript/public-api";
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
import {
K_DEV_WHALE_ACCOUNT_PRIVATE_KEY,
K_DEV_WHALE_ACCOUNT_PUBLIC_KEY,
OpenEthereumTestLedger,
pruneDockerAllIfGithubAction,
BesuTestLedger,
} from "@hyperledger/cactus-test-tooling";
import {
LogLevelDesc,
Expand All @@ -36,11 +34,17 @@ import { K_CACTUS_XDAI_TOTAL_TX_COUNT } from "../../../main/typescript/prometheu
const testCase = "deploys contract via .json file";
describe(testCase, () => {
const logLevel: LogLevelDesc = "TRACE";
const ledger = new OpenEthereumTestLedger({ logLevel });
const ledger = new BesuTestLedger({ logLevel });
const containerImageVersion = "2021-08-24--feat-1244";
const containerImageName =
"ghcr.io/hyperledger/cactus-besu-21-1-6-all-in-one";
const besuOptions = { containerImageName, containerImageVersion };
const besuTestLedger = new BesuTestLedger(besuOptions);
const besuKeyPair = {
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
};
const contractName = "HelloWorld";
const expressApp = express();
const whalePubKey = K_DEV_WHALE_ACCOUNT_PUBLIC_KEY;
const whalePrivKey = K_DEV_WHALE_ACCOUNT_PRIVATE_KEY;
expressApp.use(bodyParser.json({ limit: "250mb" }));
const server = http.createServer(expressApp);
let addressInfo,
Expand All @@ -52,6 +56,7 @@ describe(testCase, () => {
apiHost: string,
web3: Web3,
factory: PluginFactoryLedgerConnector,
firstHighNetWorthAccount: string,
testEthAccount: Account,
keychainEntryKey: string,
keychainEntryValue: string,
Expand All @@ -60,6 +65,8 @@ describe(testCase, () => {
apiClient: XdaiApi;

beforeAll(async () => {
await besuTestLedger.start();
firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await expect(pruning).resolves.toBeTruthy();
});
Expand Down Expand Up @@ -125,12 +132,12 @@ describe(testCase, () => {

await connector.transact({
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
transactionConfig: {
from: whalePubKey,
from: firstHighNetWorthAccount,
to: testEthAccount.address,
value: 10e9,
gas: 1000000,
Expand All @@ -154,8 +161,8 @@ describe(testCase, () => {
// contractAbi: HelloWorldContractJson.abi,
constructorArgs: [],
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
gas: 1000000,
Expand All @@ -174,8 +181,8 @@ describe(testCase, () => {
methodName: "sayHello",
params: [],
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ import {
ReceiptType,
} from "../../../main/typescript/public-api";
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
import {
K_DEV_WHALE_ACCOUNT_PRIVATE_KEY,
K_DEV_WHALE_ACCOUNT_PUBLIC_KEY,
OpenEthereumTestLedger,
} from "@hyperledger/cactus-test-tooling";
import { BesuTestLedger } from "@hyperledger/cactus-test-tooling";
import { LogLevelDesc } from "@hyperledger/cactus-common";
import HelloWorldContractJson from "../../solidity/hello-world-contract/HelloWorld.json";
import Web3 from "web3";
import { PluginImportType } from "@hyperledger/cactus-core-api";

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

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

const rpcApiHttpHost = await xdaiTestLedger.getRpcApiHttpHost();

const whalePubKey = K_DEV_WHALE_ACCOUNT_PUBLIC_KEY;
const whalePrivKey = K_DEV_WHALE_ACCOUNT_PRIVATE_KEY;

const web3 = new Web3(rpcApiHttpHost);
const testEthAccount = web3.eth.accounts.create(uuidv4());

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

await connector.transact({
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
consistencyStrategy: {
blockConfirmations: 0,
receiptType: ReceiptType.NodeTxPoolAck,
},
transactionConfig: {
from: whalePubKey,
from: firstHighNetWorthAccount,
to: testEthAccount.address,
value: 10e9,
gas: 1000000,
Expand All @@ -89,8 +91,8 @@ test("deploys contract via .json file", async (t: Test) => {
const deployOut = await connector.deployContractJsonObject({
constructorArgs: [],
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
gas: 1000000,
Expand Down Expand Up @@ -118,8 +120,8 @@ test("deploys contract via .json file", async (t: Test) => {
methodName: "sayHello",
params: [],
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
contractJSON: HelloWorldContractJson,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,27 @@ import {
ReceiptType,
} from "../../../main/typescript/public-api";
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
import {
K_DEV_WHALE_ACCOUNT_PRIVATE_KEY,
K_DEV_WHALE_ACCOUNT_PUBLIC_KEY,
OpenEthereumTestLedger,
} from "@hyperledger/cactus-test-tooling";
import { BesuTestLedger } from "@hyperledger/cactus-test-tooling";
import { LogLevelDesc } from "@hyperledger/cactus-common";
import HelloWorldContractJson from "../../solidity/hello-world-contract/HelloWorld.json";
import Web3 from "web3";
import { PluginImportType } from "@hyperledger/cactus-core-api";

const logLevel: LogLevelDesc = "TRACE";
let xdaiTestLedger: OpenEthereumTestLedger;
let xdaiTestLedger: BesuTestLedger;
const testCase = "Xdai Ledger Connector Plugin";
describe(testCase, () => {
const containerImageVersion = "2021-08-24--feat-1244";
const containerImageName =
"ghcr.io/hyperledger/cactus-besu-21-1-6-all-in-one";
const besuOptions = { containerImageName, containerImageVersion };
const besuTestLedger = new BesuTestLedger(besuOptions);
const besuKeyPair = {
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
};
let firstHighNetWorthAccount: string;
let contractAddress: string;
const contractName = "HelloWorld";
const whalePubKey = K_DEV_WHALE_ACCOUNT_PUBLIC_KEY;
const whalePrivKey = K_DEV_WHALE_ACCOUNT_PRIVATE_KEY;
let keychainPlugin: PluginKeychainMemory;
let connector: PluginLedgerConnectorXdai;
let web3: Web3;
Expand All @@ -37,7 +40,7 @@ describe(testCase, () => {
let keychainEntryValue: string, rpcApiHttpHost: string;

beforeAll(async () => {
xdaiTestLedger = new OpenEthereumTestLedger({});
xdaiTestLedger = new BesuTestLedger({});
});

afterAll(async () => {
Expand All @@ -46,6 +49,7 @@ describe(testCase, () => {
});
beforeAll(async () => {
await xdaiTestLedger.start();
firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
rpcApiHttpHost = await xdaiTestLedger.getRpcApiHttpHost();
expect(rpcApiHttpHost).toBeString();

Expand Down Expand Up @@ -82,16 +86,16 @@ describe(testCase, () => {

await connector.transact({
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
consistencyStrategy: {
blockConfirmations: 0,
receiptType: ReceiptType.NodeTxPoolAck,
},
transactionConfig: {
from: whalePubKey,
from: firstHighNetWorthAccount,
to: testEthAccount.address,
value: 10e9,
gas: 1000000,
Expand All @@ -110,8 +114,8 @@ describe(testCase, () => {
// contractAbi: HelloWorldContractJson.abi,
constructorArgs: [],
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
// bytecode: HelloWorldContractJson.bytecode,
Expand All @@ -131,8 +135,8 @@ describe(testCase, () => {
methodName: "sayHello",
params: [],
web3SigningCredential: {
ethAccount: whalePubKey,
secret: whalePrivKey,
ethAccount: firstHighNetWorthAccount,
secret: besuKeyPair.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
});
Expand Down Expand Up @@ -205,7 +209,7 @@ describe(testCase, () => {
});
fail("invalid nonce should have thrown");
} catch (error: any) {
expect(error.message).toContain("Transaction nonce is too low.");
expect(error.message).toContain("Nonce too low");
}
const { callOutput: getNameOut } = await connector.invokeContract({
contractName,
Expand Down Expand Up @@ -303,9 +307,7 @@ describe(testCase, () => {
});
fail("invalid nonce should have thrown");
} catch (error: any) {
expect(error.message).toContain(
"Transaction with the same hash was already imported",
);
expect(error.message).toContain("Nonce too low");
}
const { callOutput: getNameOut } = await connector.invokeContract({
contractName,
Expand Down
Loading