Refactoring config file

This commit is contained in:
Chris Troutner
2024-03-23 17:14:26 -07:00
parent 79e3aba26e
commit 6a4aadde8a
5 changed files with 71 additions and 32 deletions
-11
View File
@@ -1,11 +0,0 @@
{
"privateKey": "KwftZ1XUKMP9cLwTjXM3Axk5dnjy28nZ7b54PMushFEYs71tXQZu",
"publicKey": "038ac0965dc75b9b98a8e1fee01d8e4bcb23770ad00d8b41f76ef3c07519e76ded",
"mnemonic": "blue unfair eye isolate capital devote horse lumber thrive second text flame",
"cashAddress": "bitcoincash:qprt28ydgfgx8da26y35us57ur5pexwjns0uvyn3qj",
"address": "bitcoincash:qprt28ydgfgx8da26y35us57ur5pexwjns0uvyn3qj",
"legacyAddress": "17SsGH7mb4nQEVh7hwTPYbYbgmWTnyWf3y",
"hdPath": "m/44'/245'/0'/0/0",
"slpAddress": "simpleledger:qprt28ydgfgx8da26y35us57ur5pexwjnsr88lx37v",
"nextAddress": 1
}
+11 -7
View File
@@ -59,7 +59,7 @@ describe('#wallet', () => {
// Mock dependencies
uut.BchWallet = MockBchWallet
// Ensure we open the test file, not the production wallet file.
uut.WALLET_FILE = testWalletFile
uut.walletFile = testWalletFile
const result = await uut.openWallet()
// console.log('result: ', result)
assert.property(result, 'mnemonic')
@@ -75,7 +75,7 @@ describe('#wallet', () => {
it('should open existing wallet file', async () => {
// This test case uses the file created in the previous test case.
// Ensure we open the test file, not the production wallet file.
uut.WALLET_FILE = testWalletFile
uut.walletFile = testWalletFile
const result = await uut.openWallet()
// console.log('result: ', result)
assert.property(result, 'mnemonic')
@@ -91,7 +91,7 @@ describe('#wallet', () => {
it('should catch and throw an error', async () => {
try {
// Force an error
uut.WALLET_FILE = ''
uut.config.walletFile = ''
uut.BchWallet = () => {
}
await uut.openWallet()
@@ -116,7 +116,7 @@ describe('#wallet', () => {
uut.config.authPass = 'fake-auth-pass'
// Ensure we open the test file, not the production wallet file.
uut.WALLET_FILE = testWalletFile
uut.config.walletFile = testWalletFile
const walletData = await uut.openWallet()
// console.log('walletData: ', walletData)
@@ -146,15 +146,19 @@ describe('#wallet', () => {
const mockWallet = new BchWallet()
await mockWallet.walletInfoPromise
sandbox.stub(mockWallet, 'initialize').resolves()
// Mock dependencies
sandbox.stub(uut, '_instanceWallet').resolves(mockWallet)
// Ensure we open the test file, not the production wallet file.
uut.WALLET_FILE = testWalletFile
uut.config.walletFile = testWalletFile
const walletData = await uut.openWallet()
// console.log('walletData: ', walletData)
// Force desired code path
uut.config.useFullStackCash = true
uut.config.walletInterface = 'web2'
const result = await uut.instanceWalletWithoutInitialization(walletData)
// console.log('result: ', result)
assert.property(result, 'walletInfoPromise')
assert.property(result, 'walletInfo')
@@ -170,7 +174,7 @@ describe('#wallet', () => {
sandbox.stub(uut, '_instanceWallet').resolves(mockWallet)
// Ensure we open the test file, not the production wallet file.
uut.WALLET_FILE = testWalletFile
uut.config.walletFile = testWalletFile
const walletData = await uut.openWallet()
// console.log('walletData: ', walletData)