In SmartPy you can do this: code
The IDE has an output panel that you can use to check all the calls and updated storage, hope it helps :)
import smartpy as sp
class MyContract(sp.Contract):
def __init__(self, **kargs):
self.init(**kargs)
@sp.entry_point
def send_tez(self):
# Do some stuff
self.data.previousAmount = self.data.latestAmount;
self.data.latestAmount = sp.amount
@sp.entry_point
def dont_allow_amount(self):
sp.verify(sp.amount == sp.tez(0), message = "Entrypoint doesn't allow amount.")
@sp.add_test(name = "Amount recording")
def test():
scenario = sp.test_scenario()
scenario.h1("Amount recording")
c1 = MyContract(latestAmount = sp.tez(0), previousAmount = sp.tez(0))
scenario += c1
scenario += c1.send_tez().run(amount = sp.tez(1))
scenario += c1.send_tez().run(amount = sp.tez(2))
scenario += c1.send_tez().run(amount = sp.tez(3))
# amount > 0 is rejected in the other entrypoint
scenario += c1.dont_allow_amount().run(amount = sp.tez(1), valid = False)
# amount = 0 is fine
scenario += c1.dont_allow_amount().run(amount = sp.tez(0))