Test against over spending #2024
Unanswered
pierrekttipay
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hey, @pierrekttipay, thanks for asking and opening the discussion. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As a proof of concept. I would like to write some client code to test against double spending. Let me explain.
I would like to have this sequence of 3 events happen at a massive scale with the last 2 competing with each other:
each time creating new Account (incrementing X) and repeating this over and over again.
My worry is if event-2 lookup the balance, see 100 while event-3 happen to do the same thing at the same time and see 100 as well. I want to test that one of the transaction will actually fail and will not end up with a negative balance.
In order to prevent that, the client will have to check if the balance will be > 0 after executing the withdraw and reject the transaction if otherwise.
Because the event-2 and event-3 compete at the same time. Some account will have a balance of 50, some will have a balance of 40 (because event-3 was applied before event-2 in that occurance)
Can someone please help me model this simple problem in either: Go, Python or Node please?
Beta Was this translation helpful? Give feedback.
All reactions