Skip to content

Commit

Permalink
Merge branch 'main' into v2-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffWScott authored Jan 25, 2023
2 parents d170cf4 + 2c0a555 commit a7aa9b1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/blockRepair.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class BlockRepair {
this.MASTERNODE_URL = nodeurl
this.db = getDatabase()
this.processor = getBlockProcessor(services, this.db)
this.running = false
}

run() {
Expand Down Expand Up @@ -41,9 +42,11 @@ class BlockRepair {
this.run()
}
} catch (e) {
this.running = false
logger.error(e)
}
logger.complete("Repairing process ended.")
this.running = false
}

async blockProcessor(blockData) {
Expand Down
27 changes: 27 additions & 0 deletions src/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,33 @@ describe("Testing websocket server.", () => {
clientSocket.disconnect();
});

test("Subscribe to the new-state-changes-by-transaction event in tx hash room ", (done) => {
let data = newblock
clientSocket.once("new-block", (msg) => {
let message = JSON.parse(msg).message
expect(message).toEqual(data)
});
clientSocket.once("new-state-changes-by-transaction", (msg) => {
let message = JSON.parse(msg).message
expect(getType(message)).toBe('object')
expect(getType(message.tx_uid)).toBe('string')
expect(getType(message.blockNum)).toBe('number')
expect(message.blockNum).toBeDefined()
expect(message.timestamp).toBeDefined()
expect(message.affectedContractsList).toBeDefined()
expect(message.affectedVariablesList).toBeDefined()
expect(message.affectedRootKeysList).toBeDefined()
//expect(message.affectedRawKeysList).toBeDefined()
expect(message.state_changes_obj).toBeDefined()
//expect(message.txHash).toBeDefined()
expect(message.txInfo).toBeDefined()
done()
});
clientSocket.emit('join', data.processed.hash)
blockProcessor(data).catch((e) => { console.log(e) })
});


test("Should get push notifications of new block after a new block was processed.", (done) => {
let data = newblock[0]
clientSocket.once("new-block", (msg) => {
Expand Down

0 comments on commit a7aa9b1

Please sign in to comment.