feat(tests): Added manual e2e tests

This commit is contained in:
Daniel Gonzalez
2021-08-18 01:10:03 -04:00
parent f41cac9fc7
commit 0b72895102
6 changed files with 79 additions and 8 deletions
+3 -3
View File
@@ -20,9 +20,9 @@ async function startTest () {
await testUtils.testTransaction(testData.uutId)
// ToDo:
// testTransactions()
// testUtxos()
await testUtils.testTransactions(testData.uutId)
await testUtils.testUtxos(testData.uutId)
console.log('E2E TEST: Tests completed successfully!')
process.exit()
+67 -1
View File
@@ -99,7 +99,10 @@ class TestUtils {
announceJsonLd: announceJsonLd
})
await this.ipfsCoord.ipfs.start()
await this.ipfsCoord.isReady()
// some ipfs-coord versions do not have this function
if (this.ipfsCoord.isReady) {
await this.ipfsCoord.isReady()
}
// Wait to let ipfs-coord connect to subnet peers.
await this.bchjs.Util.sleep(30000)
@@ -195,6 +198,69 @@ class TestUtils {
}
}
// Get the info a on transaction over JSON RPC.
async testTransactions (ipfsId) {
try {
// Generate the JSON RPC command
const id = uid()
const cmd = jsonrpc.request(id, 'bch', {
endpoint: 'transactions',
addresses: ['bitcoincash:qrl2nlsaayk6ekxn80pq0ks32dya8xfclyktem2mqj']
})
const cmdStr = JSON.stringify(cmd)
// console.log(`Publishing message to ${ipfsId}`)
console.log('E2E TEST: Sending Transactions command...')
const result = await this.sendRPC(ipfsId, cmdStr)
// console.log('result: ', result)
if (result.result.value.status && Array.isArray(result.result.value.transactions)) {
console.log('E2E TEST: transactions test passed.')
return true
} else {
console.log('E2E TEST: transactions test failed.')
this.failTest()
}
} catch (err) {
console.error('Error in testTransactions()')
throw err
}
}
// Get the utxos for a BCH address over JSON RPC.
async testUtxos (ipfsId) {
try {
// Generate the JSON RPC command
const id = uid()
const cmd = jsonrpc.request(id, 'bch', {
endpoint: 'utxos',
address: 'bitcoincash:qrl2nlsaayk6ekxn80pq0ks32dya8xfclyktem2mqj'
})
const cmdStr = JSON.stringify(cmd)
// console.log(`Publishing message to ${ipfsId}`)
console.log('E2E TEST: Sending Utxos command...')
const result = await this.sendRPC(ipfsId, cmdStr)
// console.log('result', result.result.value)
const bchUtxos = result.result.value[0].bchUtxos
const slpUtxos = result.result.value[0].slpUtxos
if (result.result.value && bchUtxos && slpUtxos) {
console.log('E2E TEST: utxos test passed.')
return true
} else {
console.log('E2E TEST: utxos test failed.')
this.failTest()
}
} catch (err) {
console.error('Error in testUtxos()')
throw err
}
}
failTest () {
console.log('Exiting test program.')
process.exit()
+2 -2
View File
@@ -1,4 +1,4 @@
{
"uutAddr": "/ip4/127.0.0.1/tcp/5668/p2p/QmZSyLnRQWMBknVNjUroLQnrcmDnUVAUU4pMQ2LGhh6b9v",
"uutId": "QmZSyLnRQWMBknVNjUroLQnrcmDnUVAUU4pMQ2LGhh6b9v"
"uutAddr": "/ip4/192.168.43.115/tcp/5668/p2p/QmVBWvFxao7smhRjUUh1q8rNAEwMqbg4X3dqsQDMSjUpmx",
"uutId": "QmfUjMqUeXSCzNkFGrzvf79yvV62dtjsnwtBSYKx3wegXw"
}