mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-service.git
synced 2026-09-21 16:52:03 -07:00
Got simulated client to send a JSON RPC command
This commit is contained in:
@@ -13,6 +13,8 @@ async function startTest () {
|
||||
await testUtils.startIpfs()
|
||||
|
||||
await testUtils.connectToUut(testData.uutAddr)
|
||||
|
||||
await testUtils.getBalance(testData.uutId)
|
||||
} catch (err) {
|
||||
console.error('Error in startTest(): ', err)
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ class TestUtils {
|
||||
})
|
||||
await this.ipfsCoord.ipfs.start()
|
||||
await this.ipfsCoord.isReady()
|
||||
|
||||
// Wait to let ipfs-coord connect to subnet peers.
|
||||
await this.bchjs.Util.sleep(30000)
|
||||
} catch (err) {
|
||||
console.error('Error in startIpfs().')
|
||||
throw err
|
||||
@@ -39,12 +42,41 @@ class TestUtils {
|
||||
async connectToUut (addr) {
|
||||
try {
|
||||
await this.ipfs.swarm.connect(addr)
|
||||
console.log(`Connected to IPFS node ${addr}`)
|
||||
console.log(`E2E TEST: Connected to IPFS node ${addr}`)
|
||||
} catch (err) {
|
||||
console.error('Error in connectToUut()')
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
// Get the balance for a BCH address over JSON RPC.
|
||||
async getBalance (ipfsId) {
|
||||
try {
|
||||
const cmd = {
|
||||
jsonrpc: '2.0',
|
||||
id: '832',
|
||||
method: 'bch',
|
||||
params: {
|
||||
endpoint: 'balance',
|
||||
addresses: ['bitcoincash:qrl2nlsaayk6ekxn80pq0ks32dya8xfclyktem2mqj']
|
||||
}
|
||||
}
|
||||
const cmdStr = JSON.stringify(cmd)
|
||||
|
||||
console.log(
|
||||
'ipfs-coord peer info: ',
|
||||
this.ipfsCoord.ipfs.peers.state.peers[ipfsId]
|
||||
)
|
||||
|
||||
console.log(`Publishing message to ${ipfsId}`)
|
||||
// await this.ipfsCoord.ipfs.pubsub.publishToPubsubChannel(ipfsId, cmdStr)
|
||||
await this.ipfsCoord.ipfs.orbitdb.sendToDb(ipfsId, cmdStr)
|
||||
console.log('E2E TEST: Balance command sent.')
|
||||
} catch (err) {
|
||||
console.error('Error in getBalance()')
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const announceJsonLd = {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"uutAddr": "/ip4/127.0.0.1/tcp/5668/p2p/QmZSyLnRQWMBknVNjUroLQnrcmDnUVAUU4pMQ2LGhh6b9v"
|
||||
"uutAddr": "/ip4/127.0.0.1/tcp/5668/p2p/QmZSyLnRQWMBknVNjUroLQnrcmDnUVAUU4pMQ2LGhh6b9v",
|
||||
"uutId": "QmZSyLnRQWMBknVNjUroLQnrcmDnUVAUU4pMQ2LGhh6b9v"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user