Skip to content

Commit

Permalink
DEBUG: Unable to match provided value to a secret URI error
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Jul 17, 2023
1 parent 4a5397c commit dfbd743
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"test:comments": "--runInBand avoids race conditions with global setup",
"test": "jest --silent --runInBand",
"test": "jest --runInBand ./src/test/add-bid-order.test.ts",
"lint": "eslint -c .eslintrc.js --ext .ts ./src",
"format": "prettier --write \"src/**/*.ts\"",
"check-format": "prettier --check \"src/**/*.ts\"",
Expand Down
15 changes: 15 additions & 0 deletions integration-tests/src/testnetSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,51 @@ import { providers, Keyring, KeyringPair, Wallet } from 'creditcoin-js';
import { default as globalSetup } from './globalSetup';

const createSigner = (keyring: Keyring, who: 'lender' | 'borrower' | 'sudo'): KeyringPair => {
console.log('***** DEBUG: createSigner: ', who);
switch (who) {
case 'lender':
const lenderSeed = process.env.LENDER_SEED;
if (lenderSeed === undefined) {
console.log('***** DEBUG: createSigner: lenderSeed===undefined');
throw new Error('LENDER_SEED environment variable is required');
}
console.log('***** DEBUG: createSigner: lenderSeed.length=', lenderSeed.length);
console.log('***** DEBUG: createSigner: lenderSeed spaces=', lenderSeed.split(' ').length - 1);
return keyring.addFromUri(lenderSeed!); // eslint-disable-line
case 'borrower':
const borrowerSeed = process.env.BORROWER_SEED;

if (borrowerSeed === undefined) {
console.log('***** DEBUG: createSigner: borrowerSeed===undefined');
throw new Error('BORROWER_SEED environment variable is required');
}
console.log('***** DEBUG: createSigner: borrowerSeed.length=', borrowerSeed.length);
console.log('***** DEBUG: createSigner: borrowerSeed spaces=', borrowerSeed.split(' ').length - 1);
return keyring.addFromUri(borrowerSeed!); // eslint-disable-line
default:
throw new Error(`Unexpected value "${who}"`); // eslint-disable-line
}
};

const createWallet = (who: 'lender' | 'borrower') => {
console.log('+++++ DEBUG: createWallet', who);
const lenderPrivateKey = process.env.LENDER_PRIVATE_KEY;
if (lenderPrivateKey === undefined) {
console.log('+++++ DEBUG: createWallet, lenderPrivateKey === undefined');
throw new Error('LENDER_PRIVATE_KEY environment variable is required');
}

const borrowerPrivateKey = process.env.BORROWER_PRIVATE_KEY;
if (borrowerPrivateKey === undefined) {
console.log('+++++ DEBUG: createWallet, borrowerPrivateKey === undefined');
throw new Error('BORROWER_PRIVATE_KEY environment variable is required');
}

const privateKey = who === 'lender' ? lenderPrivateKey : borrowerPrivateKey;

console.log('+++++ DEBUG: createWallet, privateKey !== undefined; will return Wallet');
console.log('+++++ DEBUG: createWallet, privateKey.length=', privateKey.length);

const provider = new providers.JsonRpcProvider((global as any).CREDITCOIN_ETHEREUM_NODE_URL);

return new Wallet(privateKey, provider);
Expand Down

0 comments on commit dfbd743

Please sign in to comment.