-
Notifications
You must be signed in to change notification settings - Fork 230
Open
Description
Hi, thanks you for the Course, but i mention the it's possible to send minus or 0 value on amount and i think it's will be very danger.
specially for people will really run it as a production.
you can send minus amount on create Transaction eg
it will rise sender balance :) for sure -- = +
fix need 2 tests + 2 fix on classes
wallet / index.test.js
it("throws an error on mins", () => {
expect(() => {
wallet.createTransaction({
recipient: "arabto2-recipient",
amount: -100,
});
}).toThrow("incorrect amount value");
});
wallet/ index.js
if (amount <= 0) {
throw new Error("incorrect amount value");
}
------ also on update transaction -----
wallet/transaction.test.js
it("throws an error on mins", () => {
expect(() => {
transaction.update({
senderWallet,
recipient: "arabto2-recipient",
amount: -100,
});
}).toThrow("incorrect amount value");
});
wallet/transaction.js
if (amount <= 0) {
throw new Error("incorrect amount value");
}
also i think it balance shall not accept minus value , the amount also accept alphabet so i even suggest to have method on util to validate the number
Metadata
Metadata
Assignees
Labels
No labels