How do you simulate the entrypoint caller address when testing? Getting the error “Sender is undefined” error on an assert statement, which I halfway expected
File “”, line 12, in
assert sp.sender == sp.address(“tz1da6oerX2dpWHBEvnBUkcuCKQRK9b9EgTo”), “Only contract owner can call this entrypoint”
Sender is undefined: sp.sender
The function code
@sp.entrypoint
def add_eligible_delegator(self, address):
assert sp.sender == sp.address(“tz1da6oerX2dpWHBEvnBUkcuCKQRK9b9EgTo”), “Only contract owner can call this entrypoint”
#tz1da6oerX2dpWHBEvnBUkcuCKQRK9b9EgTo
this_address = sp.cast(address,sp.address)
self.data.approved_delegators[this_address] = sp.record(yay=False,nay=False,_pass=False,votingPower=0)
The test scenario call
c1.add_eligible_delegator(valid_delegator_1.address)
Looked like in previous versions of smartpy you could add the run() method to the testing call, with the sender or source parameters, but I’m assuming run() is no longer available.
Having already learned quite a bit with this small exercise, I’m willing to add this question: does anyone already have voting contract code I can steal? I want to give my delegators a chance to voice their preference for the latest proposal