Skip to content

Commit

Permalink
fix(connector-besu): remove magic strings
Browse files Browse the repository at this point in the history
and linter warnings

Fixes hyperledger#1104

Signed-off-by: Hana Awad <awadhana0825@gmail.com>
  • Loading branch information
awadhana authored and RafaelAPB committed Nov 19, 2021
1 parent 8dad868 commit baceadd
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ test("can get past logs of an account", async (t: Test) => {
*
* @see https://github.com/hyperledger/besu/blob/1.5.1/config/src/main/resources/dev.json
*/
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";

const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();

const web3 = new Web3(rpcApiHttpHost);
const testEthAccount = web3.eth.accounts.create(uuidv4());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ test(testCase, async (t: Test) => {
*
* @see https://github.com/hyperledger/besu/blob/1.5.1/config/src/main/resources/dev.json
*/
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";

const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const besuKeyPair = {
privateKey:
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
};

const web3 = new Web3(rpcApiHttpHost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test("can get balance of an account", async (t: Test) => {
*
* @see https://github.com/hyperledger/besu/blob/1.5.1/config/src/main/resources/dev.json
*/
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const web3 = new Web3(rpcApiHttpHost);
const testEthAccount = web3.eth.accounts.create(uuidv4());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test("can get past logs of an account", async (t: Test) => {
*
* @see https://github.com/hyperledger/besu/blob/1.5.1/config/src/main/resources/dev.json
*/
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();

const web3 = new Web3(rpcApiHttpHost);
const testEthAccount = web3.eth.accounts.create(uuidv4());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ test("deploys contract via .json file", async (t: Test) => {
*
* @see https://github.com/hyperledger/besu/blob/1.5.1/config/src/main/resources/dev.json
*/
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const besuKeyPair = {
privateKey:
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
};
const contractName = "HelloWorld";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory
const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const expiration = 2147483648;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const besuTestLedger = new BesuTestLedger({ logLevel });
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory
const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const expiration = 2147483648;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const besuTestLedger = new BesuTestLedger({ logLevel });
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand All @@ -61,7 +62,6 @@ test("BEFORE " + testCase, async (t: Test) => {

test(testCase, async (t: Test) => {
t.comment("Starting Besu Test Ledger");
const besuTestLedger = new BesuTestLedger({ logLevel });

test.onFinish(async () => {
await besuTestLedger.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu-erc2
const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const expiration = 2147483648;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const besuTestLedger = new BesuTestLedger({ logLevel });
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import TestTokenJSON from "../../../solidity/token-erc20-contract/Test_Token.jso
const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const expiration = 2147483648;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const besuTestLedger = new BesuTestLedger({ logLevel });
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu-erc2

const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const besuTestLedger = new BesuTestLedger({ logLevel });
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory
const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const expiration = 2147483648;
const besuTestLedger = new BesuTestLedger({ logLevel });
const secret =
"0x3853485acd2bfc3c632026ee365279743af107a30492e3ceaa7aefc30c2a048a";
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const fakeWeb3SigningCredential: Web3SigningCredential = {
ethAccount: "fakeAccount",
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test get invalid single status";

test("BEFORE " + testCase, async (t: Test) => {
Expand All @@ -74,6 +59,19 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const fakeWeb3SigningCredential: Web3SigningCredential = {
ethAccount: "fakeAccount",
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;
const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test get single status";

test("BEFORE " + testCase, async (t: Test) => {
Expand All @@ -69,6 +60,14 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test get invalid status";

test("BEFORE " + testCase, async (t: Test) => {
Expand All @@ -69,6 +60,14 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test get status";

Expand All @@ -69,6 +61,14 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test invalid initialize";

Expand All @@ -64,6 +56,14 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test initialize";

test("BEFORE " + testCase, async (t: Test) => {
Expand All @@ -64,6 +55,14 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test invalid new contract";

Expand All @@ -68,6 +60,14 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test new contract";

test("BEFORE " + testCase, async (t: Test) => {
Expand All @@ -68,6 +59,14 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Loading

0 comments on commit baceadd

Please sign in to comment.