def test(): scenario = sp.test_scenario() scenario.h1("ExchangeRateOracle Tests") admin = sp.test_account("Admin") scenario.show(admin) operatorA = sp.test_account("operatorA") scenario.show(operatorA) operatorB = sp.test_account("operatorB") scenario.show(operatorB) caller = sp.test_account("caller") scenario.show(caller) oracle = ExchangeRateOracle(admin.address) scenario.register(oracle) consumer = ExchangeRateConsumer(oracle.address) scenario.register(consumer) scenario += oracle.updateOperatorList(operators = sp.set([operatorA.address, operatorB.address])).run(sender = admin) scenario += oracle.registerFeed(currencyPair = "USDEUR", cost = sp.mutez(1000)).run(sender = admin) scenario += oracle.updateFeed(currencyPair = "USDEUR", value = sp.nat(92), precision = sp.nat(2), timestamp = sp.timestamp(0), source = "Trusted Source").run(sender = operatorA) scenario += consumer.sendQuery(currencyPair = "USDEUR").run(sender = caller, amount = sp.mutez(1000)) scenario.verify(consumer.data.value == 92) scenario.verify(consumer.data.currencyPair == "USDEUR")
def test(): scenario = sp.test_scenario() # GIVEN multisig and DAO addresses multisigAddress = sp.address("tz1hoverof3f2F8NAavUyTjbFBstZXTqnUMS") daoAddress = sp.address("KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9") # AND a box contract box = Box(governorAddress=multisigAddress) scenario += box # AND a break glass contract targeting the box breakGlass = LiquidityPoolBreakGlass( daoAddress=daoAddress, multisigAddress=multisigAddress, targetAddress=box.address, ) scenario += breakGlass # AND the box is governed by the break glass scenario += box.updateGovernorAddress( breakGlass.address).run(sender=multisigAddress) # WHEN glass is broken by the multisig scenario += breakGlass.breakGlass(multisigAddress).run( sender=multisigAddress) # THEN control is reverted to the multisig. scenario.verify(box.data.governorAddress == multisigAddress)
def test(): obj = VotingContract() scenario = sp.test_scenario() scenario+=obj scenario+=obj.set_candidate(candidate="Modi") scenario+=obj.vote(candidate="Modi") scenario+=obj.set_candidate(candidate="Modi")
def test(): admin = sp.address("tz1hPnEdcKWrdeZEAQiGfmV6knHA5En1fCwQ") # Put Buyers token = sp.address("KT1KtyJeL78tdHnzwCPE8M14WDb1zqsnLkjQ") bob = sp.address("tz1678") # Put Sellers alice = sp.address("tz1456") alex = sp.address("tz1910") scenario = sp.test_scenario() c1 = PutOptions(admin,10,20,token) scenario += c1 scenario += c1.RestartCycle().run(sender=admin,now=30) scenario += c1.putBuyer(StrikePrice=400,Options=1,expire=14).run(now=50,sender=bob,valid=False) scenario += c1.putSeller(amount=50000).run(now=45,sender=alice,amount=sp.tez(100000)) scenario += c1.putSeller(amount=10000).run(now=45,sender=alice) scenario += c1.putSeller(amount=10000).run(now=45,sender=alex) scenario += c1.putBuyer(StrikePrice=400,Options=1,expire=14).run(now=50,sender=bob) #scenario += c1.ResetContract().run(sender=alice,now=1209655) # scenario += c1.ModifyPrice(price=300).run(sender=admin) # scenario += c1.ReleaseContract().run(sender=bob)
def test(): scenario=sp.test_scenario() scenario.h1("Fails when data is pushed from bad address") scenario.h2("GIVEN a Normalizer contract whitelisted to an address") contract=NormalizerContract( oracleContractAddress=defaultOracleContractAddress ) scenario += contract scenario.h2("WHEN an update is pushed from the wrong address") scenario.h2("THEN the update fails.") badAddress=sp.address("KT1FrRkunqmB7futF3EyRwTt8f7fPEVJW39P") scenario += contract.update( makeMap( assetCode="XTZ-USD", start=sp.timestamp(1595104501), end=sp.timestamp(1595104531), open=3059701, high=1, low=2, close=3, volume=4 ) ).run(sender=badAddress, valid=False)
def test(): scenario = sp.test_scenario() contract = Transaction() scenario += contract scenario.h3("Transact") scenario += contract.transaction(destiny=sp.address("tz1")).run(sender=sp.address("tz2"), amount=sp.tez(3000))
def test(): # We define a test scenario, together with some outputs and checks scenario = sp.test_scenario() scenario.h1("Freelantzer Test") # We first define a contract and add it to the scenario c1 = Freelantzer() scenario += c1 lister = sp.test_account("Lister") applier = sp.test_account("Applier") applier2 = sp.test_account("Applier2") applier3 = sp.test_account("Applier3") scenario += c1.list_job(_job_id="1", _company="Company Name", _job_description="link", _contact="+91-9999999999", _max_hires=1).run(source=lister, amount=sp.mutez(1000)) scenario += c1.list_job(_job_id="1", _company="Company Name", _job_description="link", _contact="+91-9999999999", _max_hires=1).run(source=lister, amount=sp.mutez(1000), valid=False) scenario += c1.apply_for_job(_job_id="1", _resume="resume link").run(source=applier) scenario += c1.apply_for_job(_job_id="1", _resume="resume link").run(source=applier) scenario += c1.hire(_job_id="1", _candidate=applier.address, _offer_letter="letter").run(source=lister) scenario.verify(c1.balance == sp.mutez(1000)) scenario += c1.submit(_job_id="1", _candidate=applier.address).run(source=applier, valid=False) scenario += c1.submit(_job_id="1", _candidate=applier.address).run(source=lister) scenario.verify(c1.balance == sp.mutez(0)) scenario += c1.list_job(_job_id="1", _company="Company Name", _job_description="link", _contact="+91-9999999999", _max_hires=2).run(source=lister, amount=sp.mutez(1000)) scenario += c1.apply_for_job(_job_id="1", _resume="resume link").run(source=applier) scenario += c1.apply_for_job(_job_id="1", _resume="resume link").run(source=applier2) scenario += c1.apply_for_job(_job_id="1", _resume="resume link").run(source=applier3) scenario += c1.hire(_job_id="1", _candidate=applier.address, _offer_letter="letter").run(source=lister) scenario += c1.hire(_job_id="1", _candidate=applier2.address, _offer_letter="letter").run(source=lister) scenario += c1.hire(_job_id="1", _candidate=applier3.address, _offer_letter="letter").run(source=lister, valid=False) scenario += c1.submit(_job_id="1", _candidate=applier.address).run(source=lister) scenario += c1.submit(_job_id="1", _candidate=applier3.address).run(source=lister, valid=False) scenario.verify(c1.balance == sp.mutez(500)) scenario += c1.submit(_job_id="1", _candidate=applier2.address).run(source=lister) scenario.verify(c1.balance == sp.mutez(0))
def test(): scenario = sp.test_scenario() admin = sp.address("tz1LAWQmxJcnK43vR9G8jsNTzR6b2unZ58NX") alice = sp.test_account("Alice") bob = sp.test_account("Robert") alex = sp.test_account("Alex") c1 = ALAToken(admin) c2 = PutOptions(admin,100,120,c1.address) scenario += c1 scenario += c2 scenario += c1.AddContract(c2.address).run(sender=admin) scenario += c1.mint(address = alice.address, value = 2).run(sender = alice,amount = sp.tez(2)) scenario += c2.putSeller(amount=50000).run(now=45,sender=alice,amount=sp.tez(100000)) scenario += c1.mint(address = bob.address, value = 1).run(sender = bob,amount = sp.tez(1)) scenario += c2.putBuyer(StrikePrice=400,Options=1,expire=14).run(now=50,sender=bob) scenario += c2.WithdrawPremium().run(sender=alice) # scenario += c2.ModifyPrice(price=300).run(sender=admin) # scenario += c2.ReleaseContract().run(sender=bob)
def test(): scenario = sp.test_scenario() admin = sp.test_account("Alice") alice = sp.test_account("Alice") bob = sp.test_account("Robert") alex = sp.test_account("Alex") token = sp.address("KT1KtyJeL78tdHnzwCPE8M14WDb1zqsnLkjQ") oracle = XTZOracle(admin.address) scenario += oracle c1 = PutOptions(admin.address,10,20,token,oracle.address) scenario += c1 scenario += oracle.feedData(price=400).run(sender=admin) scenario += oracle.feedData(price=600).run(sender=admin) scenario += oracle.feedStrike(one=320,two=360,three=400,four=440,five=480).run(sender=admin) scenario += oracle.GetputSeller(Options=1,Ratio=80,address=admin.address,expire=14).run(sender=admin) scenario += c1.RestartCycle().run(sender=admin,now=30) scenario += c1.putSeller(amount=50000).run(now=45,sender=alice,amount=sp.tez(100000)) scenario += c1.putSeller(amount=10000).run(now=45,sender=alice) scenario += c1.putSeller(amount=10000).run(now=45,sender=alex) scenario += c1.putBuyer(Options=1,StrikePrice=100,expire=7).run(sender=bob) #scenario += oracle.getDataMint(address=alice.address,amount=10).run(sender=alice)
def test(): # Required to rest the contract in smartpy scenario = sp.test_scenario() #add header for output scenario.h1("String Test") # Initialize test addresses firstOwner = sp.address("tz1-firstOwner-address-1234") secondOwner = sp.address("tz1-secondOwner-address-5678") # Instantiate EventPlanner contract c1 = EventPlanner(firstOwner) #add header for output scenario.h2("Output") scenario += c1 # Invoke EventPlanner entry points and print results to HTML scenario.h2("Set date for Tezos Meetup to 11-28-2017") scenario += c1.setDate(name = "Tezos Meetup", newDate = "11-28-2017").run(sender = firstOwner) scenario.h2("Set number of guests for Tezos Meetup to 80") scenario += c1.setNumGuests(name = "Tezos Meetup", newNumGuests = 80).run(sender = firstOwner) scenario.h2("Change owner") scenario += c1.changeOwner(newOwner = secondOwner).run(sender = firstOwner) scenario.h2("New owner sets date for Tezos Meetup to 03-21-2019") scenario += c1.setDate(name = "Tezos Meetup", newDate = "03-21-2019").run(sender = secondOwner) scenario.h2("Old owner attempts to set date for Tezos Meetup") scenario += c1.setDate(name = "Tezos Meetup", newDate = "10-15-2018").run(sender = firstOwner, valid = False)
def test(): alice = sp.test_account("Alice") bob = sp.test_account("Robert") scenario = sp.test_scenario() scenario.h1("Atomic Swap") # Here, two AtomicSwap contracts are created. One with Alice as the owner # and Bob as the counterparty, and the second with the identities reversed. # They are both secured with the same hash secret, so if the secret gets # revealed, then both swaps can happen. hashSecret = sp.blake2b(sp.bytes("0x12345678aabb")) c1 = AtomicSwap(sp.mutez(12), sp.timestamp(50), hashSecret, alice.address, bob.address) c2 = AtomicSwap(sp.mutez(20), sp.timestamp(50), hashSecret, bob.address, alice.address) scenario.h1("c1") scenario += c1 scenario += c1.knownSecret(secret = sp.bytes("0x12345678aa")).run(sender = bob, valid = False) scenario += c1.knownSecret(secret = sp.bytes("0x12345678aabb")).run(sender = bob) scenario.h1("c2") scenario += c2 scenario.h2("C2.export()") scenario.p(c2.export())
def test(): scenario = sp.test_scenario() admin = sp.address("tz1XP2AUZAaCbi1PCNQ7pEdMS1EEjL4p4YPY") mark = sp.test_account("Mark") elon = sp.test_account("Mars") alice = sp.test_account("alice") # (1) Initialize Cryptobot as `cryptobot` with non_fungible set to True. # (2) Add it to the scenario. cryptobot = Cryptobot(FA2.FA2_config(non_fungible = True), admin) scenario += cryptobot # Mint 1 token to mark with symbol - "CTB", amount - 1, token_id - 0 and extras - {"value": "First bot"} scenario += cryptobot.mint(address = mark.address, amount = 1, symbol = 'CTB', token_id = 5, extras = { "value": "4th bot"}).run(sender = admin) # Mint 1 token to mark with symbol - "CTB", amount - 1, token_id - 1 and extras - {"value": "Second bot"} scenario += cryptobot.mint(address = elon.address, amount = 1, symbol = 'CTB', token_id = 6, extras = { "value": "Second bot" }).run(sender = admin) scenario += cryptobot.offer_bot_for_sale(token_id = 6, min_sale_price = sp.mutez(1000)).run(sender = elon) # scenario += cryptobot.bot_no_longer_for_sale(token_id = 6).run(sender = elon) scenario += cryptobot.enter_bid_for_bot(token_id = 6).run(sender = mark, amount = sp.mutez(10000000)) scenario += cryptobot.enter_bid_for_bot(token_id = 6).run(sender = alice, amount = sp.mutez(12000000)) scenario += cryptobot.widthdraw_bid_for_bot(token_id = 6).run(sender = alice) scenario += cryptobot.accept_bid_for_bot(token_id = 6, nft_amount = 1).run(sender = elon)
def test(): scenario = sp.test_scenario() # sp.test_account generates ED25519 key-pairs deterministically: admin = sp.test_account("Admin") alice = sp.test_account("Alice") bob = sp.test_account("Bob") robert = sp.test_account("Robert") scenario.h1("Contract") oracle = USDOracle(admin.address) scenario += oracle options = Securities(sp.address("tz1XfbFQgxj1sSfe2YyJPba5ZQuKMcV4FXAX"),sp.address("KT1HsVdNMvy4uTeorCFJD2kPVGzHXhpzJZjV"),oracle.address) scenario += options scenario += oracle.feedData(price=230).run(sender=admin) scenario += options.ContractWriter(amount=1000000000).run(sender=alice) scenario += options.ContractWriter(amount=2000000000).run(sender=robert) scenario += oracle.changeSecurities(address=options.address).run(sender=admin) scenario += oracle.SecuritiesPurchase(xtz = 1000000, token = 1000000000 , duration = 1 , spender = bob.address, order = 1).run(sender = bob) scenario += oracle.feedData(price=200).run(sender=admin) scenario += oracle.SecuritiesExercise(owner = bob.address).run(sender = bob )
def test(): # DAO Contract testing# scenario = sp.test_scenario() scenario.h1("Accounts") #scenarionew.show([newadmin, newalice, newbob]) admin = sp.test_account("Administrator") alice = sp.test_account("Alice") bob = sp.test_account("Robert") scenario.show([admin, alice, bob]) daoContract = DAOContract(_Admin=admin.address, members=5, amt=10) fa12 = FA12(daoContract.address) scenario.show([daoContract.address]) scenario.show([fa12.address]) scenario +=daoContract #scenario.h1("Initialize") #scenario += daoContract.intialize(fa12.address).run(sender = admin) scenario.h2("AddRequest") scenario += daoContract.addrequest(amt=10).run(sender=alice)
def test(): scenario = sp.test_scenario() # GIVEN a token contract token = FA12.FA12(admin=Addresses.GOVERNOR_ADDRESS) scenario += token # AND a reserve contract reserve = FarmRewardReserve( rewardTokenAddress=token.address, revokeAddress=Addresses.REVOKE_ADDRESS, ) scenario += reserve # AND the reserve contract has some tokens. tokenAmount = 123456789 scenario += token.mint( sp.record( address=reserve.address, value=tokenAmount)).run(sender=Addresses.GOVERNOR_ADDRESS) # WHEN revoke is called by someone other than the governor # THEN the call fails revokeAmount = 500 scenario += reserve.revoke(revokeAmount).run( sender=Addresses.NULL_ADDRESS, valid=False, )
def test(): scenario = sp.test_scenario() scenario.h1("FA2 Contract Name: " + config.name) scenario.table_of_contents() # sp.test_account generates ED25519 key-pairs deterministically: admin = sp.test_account("Administrator") alice = sp.test_account("Alice") bob = sp.test_account("Robert") # Let's display the accounts: scenario.h2("Accounts") scenario.show([admin, alice, bob]) c1 = FA2(config, admin.address) scenario += c1 if config.non_fungible: # TODO return scenario.h2("Initial Minting") scenario.p("The administrator mints 100 token-0's to Alice.") scenario += c1.mint(address = alice.address, amount = 100, symbol = 'TK0', token_id = 0).run(sender = admin) scenario.h2("Create certificate") scenario += c1.create_certificate(months = 5).run(sender = bob, amount=sp.mutez(100000000)) scenario.h2("redeem certificate") scenario += c1.redeem_certificate(token_id = 1).run(sender = bob)
def test(): acc = sp.test_account(2) c1 = Wuwei(acc.address, '0x') scenario = sp.test_scenario() scenario.h1("Wuwei Deployment") scenario += c1 scenario.h1("Round inputs") scenario += c1.prices_input( OBJ={ 'CNY': 545, 'BRL': 3131, 'EUR': 242, 'CAN': 5453, 'INR': 42342, 'JPY': 13123, 'KRW': 4232, 'RUB': 52554, 'CHF': 242, 'HKD': 423433, 'SGD': 423, 'AED': 4333, 'QAR': 34 }) scenario.h1("Initialize Client") c2 = Client() scenario += c2 scenario.h1("Request value from key") scenario += c2.request_key(kt=c1.address, key='BRL')
def test(): c1 = HENDao([sp.address("tz1owner1"), sp.address("tz1owner2")]) scenario = sp.test_scenario() scenario.h1("Test Buy") scenario += c1 user1 = sp.address("tz1owner1") user2 = sp.address("tz1owner2") scenario.h2("Buying disabled when locked") c1.vote_buy(swap_id=sp.nat(123), price=sp.mutez(0), objkt_amount=sp.nat(1)).run(valid=False, sender=user1) scenario.h2("Buying enabled when unlocked") c1.vote_lock(True).run(sender=user1) c1.vote_lock(True).run(sender=user2) c1.vote_buy(swap_id=sp.nat(123), objkt_amount=sp.nat(1), price=sp.mutez(0)).run(sender=user1) # Proposal should pass c1.vote_buy(swap_id=sp.nat(123), objkt_amount=sp.nat(1), price=sp.mutez(0)).run(sender=user2) scenario.verify(c1.data.buy_proposals[123].passed == True) # Double vote fails c1.vote_buy(swap_id=sp.nat(123), objkt_amount=sp.nat(1), price=sp.mutez(0)).run(sender=user2, valid=False) c1.vote_buy(swap_id=sp.nat(123), objkt_amount=sp.nat(1), price=sp.mutez(0)).run(sender=user1, valid=False) # Test undo c1.vote_buy(swap_id=sp.nat(456), objkt_amount=sp.nat(1), price=sp.mutez(5)).run(sender=user1) c1.undo_vote_buy(456).run(sender=user1) scenario.verify(c1.data.buy_proposals[456].votes.contains(user1) == False)
def test(): scenario = sp.test_scenario() scenario.h1("ALA Contract") value = 1 admin = sp.address("tz123") alice = sp.address("tz1456") bob = sp.address("tz1678") c1 = ALACoin(admin) c2 = Options(c1.address,admin) scenario += c1 scenario += c2 scenario += c1.mint(address = alice, amount = 12).run(sender = alice,amount = sp.tez(12)) scenario += c1.mint(address = bob, amount = 10).run(sender = alice,amount = sp.tez(10)) scenario += c1.AddContract(c2.address).run(sender=admin) scenario += c2.Payment().run(sender=alice) # scenario += c1.LockToken(address = bob, amount = 10).run(sender = admin) # scenario += c1.UnlockToken(address = bob, amount = 10).run(sender = admin) # scenario += c1.withdraw().run(sender = bob)
def test(): # init test and create html output scenario = sp.test_scenario() scenario.h1("SmartPy Proxy Contract") # init test values owner = sp.test_account("owner") notOwner = sp.test_account("notOwner") oldContract = sp.test_account("old") newContract = sp.test_account("new") # init contract proxy = Proxy(oldContract.address, owner.address) scenario += proxy # sanity check scenario.verify(proxy.data.contract == oldContract.address) # test entrypoints scenario.h2("[ENTRYPOINT] setAddr") scenario.h3("[SUCCESS-setAddr]") scenario += proxy.setAddr(newAddr=newContract.address).run(sender=owner) scenario.verify(proxy.data.contract == newContract.address) scenario.h3("[FAILED-setAddr] Invalid permissions") scenario += proxy.setAddr(newAddr=oldContract.address).run(sender=notOwner, valid=False)
def test(): scenario = sp.test_scenario() scenario.table_of_contents() # define test users admin = sp.test_account("Admin") alice = sp.test_account("Alice") bob = sp.test_account("Bob") fake_token = sp.test_account("Token") fake_factory = sp.test_account("Factory") fake_exchange = sp.test_account("Exchange") # define a contract scenario.p("We start with accounts:") scenario.show( [admin, alice, bob, fake_token, fake_factory, fake_exchange]) # show its representation scenario.h2("Factory contract") factory = Factory() scenario += factory scenario.h3("Launch Exchange with random addr") scenario += factory.LaunchExchange( token=fake_token.address, exchange=fake_exchange.address).run(sender=admin) scenario.h3("Launch another time") scenario += factory.LaunchExchange(token=fake_token.address, exchange=fake_exchange.address).run( sender=admin, valid=False)
def test(): scenario = sp.test_scenario() scenario.h1("NFT Contract") admin = sp.test_account("Administrator") alice = sp.test_account("Alice") bob = sp.test_account("Bob") robert = sp.test_account("Robert") dibs = sp.test_account("Dibyo") # Let's display the accounts: scenario.h2("Accounts") scenario.show([admin, alice, bob, robert,dibs]) c1 = TezNFT("state","ST",admin.address) scenario += c1 scenario.h2("Admin minting Tokens") scenario += c1.mintCertificate(token_id = "Kitty1", address = alice.address, name="Alice", score = 20).run(valid = True, sender = admin) scenario += c1.mintCertificate(token_id = "Kitty2", address = bob.address, name="Bob", score = 50).run(sender = admin) scenario += c1.mintCertificate(token_id = "Kitty3", address = bob.address, name="Bob", score = 20).run(sender = admin) scenario += c1.mintCertificate(token_id = "Kitty5", address = alice.address, name="Alice", score = 100).run(sender = admin) scenario += c1.burnCertificate(token_id = "Kitty2").run(valid= True, sender = admin)
def test(): scenario = sp.test_scenario() scenario.h1("FA1.2 template - Fungible assets") # sp.test_account generates ED25519 key-pairs deterministically: admin = sp.address("tz1LAWQmxJcnK43vR9G8jsNTzR6b2unZ58NX") alice = sp.test_account("Alice") bob = sp.test_account("Robert") # Let's display the accounts: scenario.h1("Accounts") scenario.h1("Contract") c1 = ALAToken(admin) scenario.h1("Entry points") scenario += c1 scenario.h2("Admin mints a few coins") scenario += c1.mint(address = alice.address, value = 12).run(sender = alice,amount = sp.tez(12)) scenario += c1.mint(address = bob.address, value = 3).run(sender = admin,amount=sp.tez(3)) # scenario += c1.mint(address = alice.address, value = 3).run(sender = admin) scenario += c1.AddContract(alice.address).run(sender=admin) scenario += c1.UnlockToken(address=bob.address,amount=100).run(sender=alice) scenario += c1.LockToken(address=bob.address,amount=100).run(sender=alice) scenario += c1.withdrawToken(amount=120000).run(sender=alice)
def test(): scenario = sp.test_scenario() admin = sp.test_account("Administrator") alice = sp.test_account("Alice") bob = sp.test_account("Bob") robert = sp.test_account("Robert") dibs = sp.test_account("Dibyo") # Let's display the accounts: scenario.h2("Accounts") scenario.show([admin, alice, bob, robert,dibs]) c1 = DataTokenizer("state","ST",admin.address) scenario += c1 scenario.h2("Admin minting Tokens") scenario += c1.mintDataToken(token_id = "Kitty1", address = alice.address).run(sender = admin) scenario += c1.mintDataToken(token_id = "Kitty2", address = bob.address).run(sender = admin) scenario += c1.mintDataToken(token_id = "Kitty3", address = bob.address).run(sender = admin) scenario += c1.burnDataToken(token_id = "Kitty4").run(valid= False, sender = admin) scenario += c1.transfer(token_id="Kitty2", to= robert.address).run(sender = bob) scenario += c1.approve(token_id = "Kitty2", approve_to=dibs.address).run(sender = robert) scenario += c1.transferFrom(f = robert.address, t= alice.address, token_id = "Kitty2").run(sender = dibs)
def test(): scenario = sp.test_scenario() # GIVEN multisig and DAO addresses multisigAddress = sp.address("tz1hoverof3f2F8NAavUyTjbFBstZXTqnUMS") daoAddress = sp.address("KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9") # AND a box contract box = Box(governorAddress=multisigAddress) scenario += box # AND a break glass contract targeting the box breakGlass = LiquidityPoolBreakGlass( daoAddress=daoAddress, multisigAddress=multisigAddress, targetAddress=box.address, ) scenario += breakGlass # AND the box is governed by the break glass scenario += box.updateGovernorAddress( breakGlass.address).run(sender=multisigAddress) # WHEN glass is attempted to be broken by someone other than the multisig. # THEN the call fails. scenario += breakGlass.breakGlass(multisigAddress).run( sender=daoAddress, valid=False, )
def test(): scenario = sp.test_scenario() # GIVEN a token contract token = FA12.FA12(admin=Addresses.GOVERNOR_ADDRESS) scenario += token # AND a reserve contract reserve = FarmRewardReserve( rewardTokenAddress=token.address, revokeAddress=Addresses.REVOKE_ADDRESS, ) scenario += reserve # AND there's an existing allowance token.approve(sp.record(spender=Addresses.FARM_ADDRESS, value=123)).run(sender=reserve.address) # WHEN giveRewardAllowance is called allowanceAmount = 500 scenario += reserve.giveRewardAllowance(allowanceAmount).run( sender=Addresses.GOVERNOR_ADDRESS) # THEN an allowance is given. scenario.verify(token.data.balances[reserve.address].approvals[ Addresses.FARM_ADDRESS] == allowanceAmount)
def test(): scenario = sp.test_scenario() scenario.h1("FA1.2 template - StableCoin") scenario.table_of_contents() # sp.test_account generates ED25519 key-pairs deterministically: admin = sp.test_account("Administrator") alice = sp.test_account("Alice") bob = sp.test_account("Robert") # Let's display the accounts: scenario.h1("Accounts") scenario.show([admin, alice, bob]) c1 = VaultOpener( sp.address("KT1HsVdNMvy4uTeorCFJD2kPVGzHXhpzJZjV"), sp.address("KT1LiKCNGz2NHvtUH6hhB9usqw8TfuAktusy"), sp.address("tz1XfbFQgxj1sSfe2YyJPba5ZQuKMcV4FXAX") ) scenario += c1 scenario += c1.OpenVault().run(sender=alice,amount=sp.tez(1)) # vault Opener - KT1Q5SPEdRTdki5fVXS7UHikFmWA2ckd3KdA
def test(): scenario = sp.test_scenario() # GIVEN a token contract token = FA12.FA12(admin=Addresses.GOVERNOR_ADDRESS) scenario += token # AND a reserve contract reserve = FarmRewardReserve( rewardTokenAddress=token.address, revokeAddress=Addresses.REVOKE_ADDRESS, ) scenario += reserve # AND the reserve contract has some tokens. tokenAmount = 123456789 scenario += token.mint( sp.record( address=reserve.address, value=tokenAmount)).run(sender=Addresses.GOVERNOR_ADDRESS) # WHEN revoke is called revokeAmount = 500 scenario += reserve.revoke(revokeAmount).run( sender=Addresses.GOVERNOR_ADDRESS) # THEN tokens are revoked scenario.verify(token.data.balances[Addresses.REVOKE_ADDRESS].balance == revokeAmount) scenario.verify(token.data.balances[reserve.address].balance == sp.as_nat(tokenAmount - revokeAmount))
def test(): #Accounts alice = sp.test_account('Alice') bob = sp.test_account('Bob') john = sp.test_account('John') anshu = sp.test_account('Anshu') ronak = sp.test_account('Ronak') scenario = sp.test_scenario() c = SimpleLottery() scenario += c scenario.h1('Lottery Test') scenario += c.buyTicket(1).run(sender = alice, amount = sp.tez(1)) scenario += c.buyTicket(1).run(sender = bob, amount = sp.tez(1)) scenario += c.buyTicket(1).run(sender = john, amount = sp.tez(1)) scenario += c.buyTicket(1).run(sender = ronak, amount = sp.tez(1)) scenario.h3('Buy Multiple (Change)') scenario += c.buyTicket(3).run(sender = anshu, amount = sp.tez(3)) scenario.h3('Final Contract Balance') scenario.show(c.balance)
def test(): scenario = sp.test_scenario() scenario.h1("FishcakeBox") admin = sp.test_account("Administrator") user1 = sp.test_account("User 1") user2 = sp.test_account("User 2") user3 = sp.test_account("User 3") scenario.show([admin, user1, user2]) token = Fishcake(admin.address) box = FishcakeBox( reward=5, token=token, tokenAddress=sp.address('KT1WVtyDPFzjMkdkihX22LR4y5ye9kGYxjvF')) scenario += token scenario += box scenario += token.mint(address=box.address, amount=100000, symbol='FISH', token_id=0).run(sender=admin) scenario += box scenario += box.redeem().run(sender=user1) scenario += box.redeem().run(sender=user2) scenario += box.redeem().run(sender=user1, valid=False)