-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
backendRequires attention on the backendRequires attention on the backendbugSomething isn't workingSomething isn't workingdatabaseRequires a database modificationRequires a database modificationhigh priorityRequires immediate attentionRequires immediate attention
Description
Summary
- The unit test for settling debt is currently non-deterministic, likely due to floating point arithmetic issues
- Avoid floating point arithmetic by measuring currency amounts in integers instead of floating points
- Switch the unit from pounds (GBP) to pence (GBX)
- See example of non-deterministic test runs here (screenshot below):
Test Code
// Check whether we can settle a debt between two users.
test("POST /debts/settle", async () => {
const server = supertest(app);
await server
.post("/debts/settle")
.send({
from: "testuser456",
to: "testuser123",
amount: 50,
})
.expect(200);
// Check whether the debt was successfully reduced by 50.
await debtModel
.findOne({
from: "testuser123",
to: "testuser456",
})
.then((debt) => {
expect(debt.amount).toBe(50);
});
});Metadata
Metadata
Assignees
Labels
backendRequires attention on the backendRequires attention on the backendbugSomething isn't workingSomething isn't workingdatabaseRequires a database modificationRequires a database modificationhigh priorityRequires immediate attentionRequires immediate attention
Projects
Status
Todo