Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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,
    )
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
 def __init__(self):
     self.init(
         origin = sp.address('tz1'),
         destiny = sp.address('tz2'),
         amount = sp.tez(0),
         immutability = sp.bool(False)
         )
Exemplo n.º 7
0
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)
            

       
Exemplo n.º 8
0
    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 )
Exemplo n.º 9
0
def test():
    certifier = sp.address("tz1gn1TN3gTXXWgSGKTjCSkkms78hbuaahSz")
    Contract= Certification(certifier)
    html=Contract.fullHtml()

    html+=Contract.certify(address=sp.address("tz1W4W2yFAHz7iGyQvFys4K7Df9mZL6cSKCp"), name="Yassine Amor").run(sender=certifier).html()
    setOutput(html)
Exemplo n.º 10
0
def test1():
    player1 = sp.address("tz1QXAD77BSjuD9W4AFq8rPTN1dk1gsDjYVG")
    player2 = sp.address("tz1SaSyYcuPB1EoMHkC4fx9y6HwipWMAq8e7")

    contract = Dama(player1, player2)
    scenario = sp.testScenario()
    scenario += contract
    
    scenario += contract.playerMove(start_x=4, start_y=1,
                                    target_x=4, target_y=0).run(sender=player1,valid = False) # will fail (Invalid move)
                                    
    scenario += contract.playerMove(start_x=4, start_y=2,
                                    target_x=4, target_y=3).run(sender=player1)

    scenario += contract.playerMove(start_x=2, start_y=5,
                                    target_x=2, target_y=3).run(sender=player2,valid = False)

    scenario += contract.playerMove(start_x=4, start_y=5,
                                    target_x=4, target_y=4).run(sender=player2)

    scenario += contract.playerMove(start_x=5, start_y=2,
                                    target_x=5, target_y=3).run(sender=player1,valid = False) # will fail (need to eat, but never eat)

    scenario += contract.playerMove(start_x=4, start_y=3,
                                    target_x=4, target_y=5).run(sender=player1)

    scenario += contract.playerMove(start_x=3, start_y=6,
                                    target_x=3, target_y=5).run(sender=player2,valid = False) # will fail (need to eat, but never eat)

    scenario += contract.playerMove(start_x=4, start_y=6,
                                    target_x=4, target_y=4).run(sender=player2)
    html = contract.fullHtml()
    setOutput(html)
Exemplo n.º 11
0
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)
Exemplo n.º 12
0
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))
Exemplo n.º 13
0
def test():
    sc = sp.testScenario()
    _tokenOwner = {}
    c1 = TRC721()
    sc += c1
    sender = sp.address(1)

    sc.h3("Balance Of")
    sc += c1.balanceOf(owner = sp.address("KT1AkvDHuXn2o6DVfprmS4XYDpNW3gt77157"))
    
    sc += c1.register().run(sender = "1")
    
    sc += c1.register().run(sender = "2")
    
    sc.h3("Mint")
    sc += c1._mint(to = sender, tokenId = 123)
    
    sc.h3("Owner Of")
    sc += c1.ownerOf(tokenId=123)
    
    sc.h3("Approve")
    sc += c1.approve(to = sp.address("dn1XPZsRJF9UuNZXbmEHq6TepSud8Xuumx4v"), tokenId = 123).run(sender = "1")
    
    sc.h3("_transferfrom")
    sc += c1._transferfromm(tokenId=123, fromm = sp.address(1), to = sp.address(2))
    
    sc.h3("clearApproval")
    sc += c1._clearApproval(tokenId=123)
Exemplo n.º 14
0
def test():
    scenario = sp.test_scenario()
    scenario.h1("Test")

    tenant_address = sp.address("tz1")
    financier_address = sp.address("tz2")
    crowd_address_1 = sp.address("tz1c")
    crowd_address_2 = sp.address("tz2c")
    crowd_address_3 = sp.address("tz3c")


    contract = House_123456789(house_price=200000,
                               deposit_amount=30000,
                               tenant_address=tenant_address,
                               financier_address=financier_address)

    scenario += contract


    test_purchases=True
    test_rents = True
    test_crowd_sale = True


    if test_purchases == True:

        scenario.h2("tenant buys from financier")
        scenario += contract.equity_from_financier_to_tenant(amount=abs(1000)).run(sender=tenant_address)

        scenario.h2("crowd buys from financier")
        scenario += contract.equity_from_financier_to_crowd(amount=abs(2000)).run(sender=tenant_address)

        scenario.h2("tenant buys from crowd")
        scenario += contract.equity_from_crowd_to_tenant(amount=abs(1000)).run(sender=tenant_address)


    if test_rents == True:

        scenario.h2("tenant pays rent to financier")
        scenario += contract.tenant_rental_payment_to_financier(amount=abs(1000)).run(sender=tenant_address)

        scenario.h2("tenant pays rent to crowd")
        scenario += contract.tenant_rental_payment_to_crowd(amount=abs(1000)).run(sender=tenant_address)

        scenario.h2("tenant pays rent to everyone")
        scenario += contract.tenant_rental_payment_to_everyone(amount=abs(1000)).run(sender=tenant_address)


    if test_crowd_sale == True:
        scenario.h2("random person 1 buys some house")
        scenario += contract.add_new_crowd_address(acquisition=2000).run(sender=crowd_address_1)
        scenario.h2("random person 2 buys some house")
        scenario += contract.add_new_crowd_address(acquisition=7000).run(sender=crowd_address_2)
        scenario.h2("random person 3 buys some house")
        scenario += contract.add_new_crowd_address(acquisition=4000).run(sender=crowd_address_3)
        
    scenario.h2("tenant pays rent to all crowd")
    scenario += contract.tenant_rental_payment_to_all_crowd(amount=10000).run(sender=tenant_address)
Exemplo n.º 15
0
def test():
    scenario = sp.test_scenario()
    clientContract = BTCUSDClient()
    scenario += clientContract
    scenario += clientContract.requestDataFromOrO(
        currency="USD",
        oracleAddress=sp.address("KT1987")).run(sender=sp.address("KT1-AAA"),
                                                amount=sp.mutez(6000))
    scenario += clientContract.receiveDataFromOrO(buy=7096, sell=7096)
def test():
    scenario = sp.test_scenario()
    clientContract = StockClient()
    scenario += clientContract
    scenario += clientContract.requestDataFromOrO(
        ticker="TSLA",
        oracleAddress=sp.address("KT1987")).run(sender=sp.address("KT1-AAA"),
                                                amount=sp.mutez(6000))
    scenario += clientContract.receiveDataFromOrO(price=7096,
                                                  marketCap=7096000)
Exemplo n.º 17
0
def test():
    scenario = sp.test_scenario()
    oracle = CompanyStockPriceOracle(sp.address('tz1XrHHchSehNudgAq1aQaoB4Bw7N4hZ1nkH'))
    scenario += oracle
    scenario += oracle.feedData(ticker = "TSLA", price = 7098 , marketCap = 7097000).run(sender=sp.address('tz1XrHHchSehNudgAq1aQaoB4Bw7N4hZ1nkH'))
    scenario += oracle.feedData(ticker = "FB", price = 5450 , marketCap = 54579100).run(sender=sp.address('tz1-AAA'))
    scenario += oracle.addDataContributor(contributor=sp.address("tz1-AAA")).run(sender=sp.address('tz1XrHHchSehNudgAq1aQaoB4Bw7N4hZ1nkH'))
    scenario += oracle.feedData(ticker = "FB", price = 5450 , marketCap = 54579100).run(sender=sp.address('tz1-AAA'))
    scenario += oracle.getDataFromOrO(ticker = "FB").run(sender=sp.address("KT1-AAA") , amount = sp.mutez(5000))
    scenario += oracle.getDataFromOrO(ticker = "FB").run(sender=sp.address("KT1-BBB") , amount = sp.mutez(4000))
Exemplo n.º 18
0
def test():
    scenario = sp.test_scenario()
    oracle = BitcoinToCurrencyDataOracle(sp.address('tz1beX9ZDev6SVVW9yJwNYA89362ZpWuDwou'))
    scenario += oracle
    scenario += oracle.feedData(currency = "USD", buy = 7098 , sell = 7097).run(sender=sp.address('tz1beX9ZDev6SVVW9yJwNYA89362ZpWuDwou'))
    scenario += oracle.feedData(currency = "INR", buy = 545791 , sell = 545791).run(sender=sp.address('tz1-AAA'))
    scenario += oracle.addDataContributor(contributor=sp.address("tz1-AAA")).run(sender=sp.address('tz1beX9ZDev6SVVW9yJwNYA89362ZpWuDwou'))
    scenario += oracle.feedData(currency = "INR", buy = 545791 , sell = 545791).run(sender=sp.address('tz1-AAA'))
    scenario += oracle.getDataFromOrO(currency = "INR").run(sender=sp.address("KT1-AAA") , amount = sp.mutez(5000))
    scenario += oracle.getDataFromOrO(currency = "INR").run(sender=sp.address("KT1-BBB") , amount = sp.mutez(4000))
Exemplo n.º 19
0
def test_example_contract():
    ownerAddress = sp.address('tz1ABC')
    user1Address = sp.address('tz1DEF')
    user2Address = sp.address('tz1GHI')
    user3Address = sp.address('tz1JKL')

    # given ... an Example contract instance with owner set
    contract = Example(owner=ownerAddress)
    scenario = sp.testScenario()
    scenario += contract

    # when
    # ... we add a participant as the owner
    # then
    # ... should succeed
    scenario += contract.addParticipant(address=user1Address).run(
        sender=ownerAddress, amount=sp.mutez(0))
    scenario += contract.addParticipant(address=user2Address).run(
        sender=ownerAddress, amount=sp.mutez(20))
    # ... adding the user to participants map
    scenario.verify(contract.data.participants.contains(user1Address))
    scenario.verify(contract.data.participants.contains(user2Address))
    # ... with the provided mutez as their initial value
    scenario.verify(contract.data.participants[user1Address] == sp.mutez(0))
    scenario.verify(contract.data.participants[user2Address] == sp.mutez(20))

    # when
    # ... we add a participant as not the owner
    # then
    # ... should fail
    scenario += contract.addParticipant(address=user3Address).run(
        sender=user3Address, amount=sp.mutez(50), valid=False)
    # ... not adding user to participants map
    scenario.verify(~contract.data.participants.contains(user3Address))

    # when
    # ... we participate as an existing user
    # then
    # ... should succeed
    scenario += contract.participate().run(sender=user1Address,
                                           amount=sp.mutez(5))
    scenario += contract.participate().run(sender=user2Address,
                                           amount=sp.mutez(7))
    # ... incrementing the user's mutez by provided amount
    scenario.verify(contract.data.participants[user1Address] == sp.mutez(5))
    scenario.verify(contract.data.participants[user2Address] == sp.mutez(27))

    # when
    # ... we attempt to participate as an non-existing user
    # then
    # ... should fail
    scenario += contract.participate().run(sender=user3Address,
                                           amount=sp.mutez(50),
                                           valid=False)
Exemplo n.º 20
0
def test():
    scenario = sp.test_scenario()
    oracle = PlayerFantasyPointsOracle(
        sp.address('tz1dJVWP5nAd2dfNQhpDQdGefQoED7aRy8qn'))
    scenario += oracle
    scenario += oracle.feedData(array=[sp.record(player_id=0, points=369, rank=1), sp.record(player_id=1, points=284, rank=2),
                                       sp.record(player_id=2, points=260, rank=3)]).run(sender=sp.address('tz1beX9ZDev6SVVW9yJwNYA89362ZpWuDwou'))
    scenario += oracle.getDataFromOrO().run(sender=sp.address("KT1-AAA"),
                                            amount=sp.mutez(5000))
    scenario += oracle.getDataFromOrO().run(sender=sp.address("KT1-BBB"),
                                            amount=sp.mutez(4000))
Exemplo n.º 21
0
def test():

    end_date=END_DATE
    admin = sp.address("ADMIN_TZ_ADDRESS")
    alice = sp.address("ALICE_TZ_ADDRESS")
    token_contract_addr = sp.address("CONTRACT_PKH")

    scenario = sp.test_scenario()
    c = CrowdFund(admin, token_contract_addr, end_date)
    scenario += c
    scenario.h3("crowdSaleContract")
    scenario += c.contribute(amount = 2).run(sender=alice, amount = sp.tez(2))
Exemplo n.º 22
0
    def test():
        c1 = HENDao([sp.address("tz1owner1"), sp.address("tz1owner2")])
        scenario = sp.test_scenario()
        scenario.h1("Test Buy")
        scenario += c1
        admin = sp.address("tz1owner1")
        user2 = sp.address("tz1owner2")

        scenario.h2("Buying disabled when locked")
        c1.vote_buy(swap_id=123).run(valid=False, sender=admin)
        
        scenario.h2("Buying enabled when unlocked")
Exemplo n.º 23
0
 def test():
     admin = sp.address("admin")
     user1 = sp.address("donkey")
     user2 = sp.address("monkey")
     c1 = ElectionMarket(admin)
     html  = c1.fullHtml()
     html += c1.addUser().run(sender = user1).html()
     html += c1.addUser().run(sender = user2).html()
     html += c1.addCandidate(candidate="Bernie Sanders", amount = 1000).run(sender = admin).html()
     html += c1.addCandidate(candidate="Elizabeth Warren", amount = 1000).run(sender = admin).html()
     html += c1.buy(candidate="Bernie Sanders", amount = 100).run(sender = user1).html()
     html += c1.sell(candidate="Bernie Sanders", amount = 50).run(sender = user1).html()
     setOutput(html)
Exemplo n.º 24
0
 def test():
     c1 = HENDao([sp.address("tz1owner1"), sp.address("tz1owner2")])
     scenario = sp.test_scenario()
     scenario.h1("Test Deposits")
     scenario += c1
     admin = sp.address("tz1owner1")
     user2 = sp.address("tz1owner2")
     hacker = sp.address("tz1hacker")
     c1.deposit().run(sender=admin, amount= sp.mutez(10))
     scenario.verify(c1.data.equity[admin] == sp.mutez(10))
     c1.deposit().run(sender=admin, amount= sp.mutez(5))
     scenario.verify(c1.data.equity[admin] == sp.mutez(15))
     c1.deposit().run(valid=False, sender=hacker, amount=sp.mutez(10))
Exemplo n.º 25
0
def test():
    scenario = sp.test_scenario()
    scenario.h1("Alert Test")

    c1 = Tzcare(sp.address("tz1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"))
    scenario += c1
    scenario.h2("Update Alert")
    scenario += c1.setAlert("AAAAAABBBBBBCCCC").run(amount=sp.tez(10))

    scenario.h2("Unlock Amount")
    scenario += c1.unlockAmount(
        sp.address("tz1YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY")).run(
            sender=sp.address("tz1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"))
Exemplo n.º 26
0
def test():
    scenario = sp.test_scenario()

    # Create HTML output for debugging
    scenario.h1("Sealed Bid Auction Factory")
    
    # Initialize test accounts
    master = sp.address("tz1-master-address-1234")
    owner = sp.address("tz1-owner-address-1234")

    # Instantiate Auction contract
    sealedBidAuctionFactory = SealedBidAuctionFactory(master_auction_contract = master, owner = owner)
    scenario += sealedBidAuctionFactory
Exemplo n.º 27
0
def test():
    # Create test scenario
    scenario = sp.test_scenario()

    # Create HTML output for debugging
    scenario.h1("English Auction Factory")
    
    # Initialize test accounts
    master = sp.address("tz1-master-address-1234")
    owner = sp.address("tz1-owner-address-1234")

    # Instantiate english auction factory contract
    englishAuctionFactory = EnglishAuctionFactory(master_auction_contract = master, owner = owner)
    scenario += englishAuctionFactory
Exemplo n.º 28
0
def test():
    scenario = sp.test_scenario()
    scenario.h1("Trustless Delegation Bond Tests")

    discountSchedule = {0 : 952380, 1 : 957557, 2 : 962763, 3 : 967996, 4 : 973258, 5 : 978548, 6 : 983868, 7 : 989216,
8 : 994593, 9 : 1000000}
    duration = 60*60*24*10
    interval = 60*60*24
    baker = sp.address("tz1aoLg7LtcbwJ2a7kfMj9MhUDs3fvehw6aa")
    issuer = sp.address("tz1aoLg7LtcbwJ2a7kfMj9MhUDs3fvehw6aa")

    # init contract
    instrument = Instrument(discountSchedule, duration, interval, baker, issuer)
    scenario += instrument
Exemplo n.º 29
0
def test():
    scenario = sp.test_scenario()
    contract = VisitorBook()
    scenario += contract
    
    scenario.h1("Visitor Book")
    
    scenario.h2("Visitor tz1 comes first")
    scenario += contract.write(data = "I am here!").run(sender = sp.address("tz1"))
    
    scenario.h2("Visitor tz2 comes first")
    scenario += contract.write(data = "My name is tz2!").run(sender = sp.address("tz2"))
    
    scenario.h2("Visitor tz1 comes again")
    scenario += contract.write(data = "tz1 is back!").run(sender = sp.address("tz1"))
Exemplo n.º 30
0
def test():
    scenario = sp.test_scenario()
    scenario.h1("Test Store Value")
    
    # We first define a contract and add it to the scenario
    contract = StoreValue(12)
    scenario += contract 
    scenario += contract.double()
    scenario += contract.replace(value=4)
    scenario += contract.divide(value=3).run(sender = sp.address("tz1234"))
    
    # Finally, we check its final storage
    scenario.verify(contract.data.storedValue == 1)

    scenario += contract.computeSum(augend = 1, addend = 2).run(sender = sp.address("tz1234"))