mirror of
https://github.com/hackku21/loc-chain-backend.git
synced 2024-10-27 20:34:03 +00:00
Add exposure notification example to reference implementation
This commit is contained in:
parent
d8cae0f559
commit
f0005a9ed3
@ -16,6 +16,13 @@ class TestClient {
|
|||||||
return bcrypt.hashSync(`${lesserId}-${greaterId}`, this.salt)
|
return bcrypt.hashSync(`${lesserId}-${greaterId}`, this.salt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildExposure() {
|
||||||
|
return {
|
||||||
|
clientID: this.id,
|
||||||
|
timestamp: (new Date).getTime(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async interactWith(otherClient) {
|
async interactWith(otherClient) {
|
||||||
const hash = otherClient.getHash(this.id)
|
const hash = otherClient.getHash(this.id)
|
||||||
const message = openpgp.Message.fromText(hash)
|
const message = openpgp.Message.fromText(hash)
|
||||||
@ -43,9 +50,15 @@ class TestClient {
|
|||||||
const a_transact = await client_a.interactWith(client_b)
|
const a_transact = await client_a.interactWith(client_b)
|
||||||
const b_transact = await client_b.interactWith(client_a)
|
const b_transact = await client_b.interactWith(client_a)
|
||||||
|
|
||||||
|
// Simulate an encounter between A and B
|
||||||
console.log(a_transact, b_transact)
|
console.log(a_transact, b_transact)
|
||||||
postTo('/api/v1/encounter', a_transact)
|
postTo('/api/v1/encounter', a_transact)
|
||||||
postTo('/api/v1/encounter', b_transact)
|
postTo('/api/v1/encounter', b_transact)
|
||||||
|
|
||||||
|
// Simulate B being exposed
|
||||||
|
const b_exposure = client_b.buildExposure()
|
||||||
|
console.log(b_exposure)
|
||||||
|
postTo('/api/v1/exposure', b_exposure)
|
||||||
})()
|
})()
|
||||||
|
|
||||||
function postTo(endpoint, data) {
|
function postTo(endpoint, data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user