Exemple #1
0
import tonos_ts4.ts4 as ts4, json

eq = ts4.eq
bt = 1000000

ts4.set_verbose(True)
ts4.set_tests_path('../build/')
ts4.G_WARN_ON_UNEXPECTED_ANSWERS = True

plat = ts4.core.load_code_cell('../build/DensPlatform.tvc')
cert = ts4.core.load_code_cell('../build/DensCertificate.tvc')
auct = ts4.core.load_code_cell('../build/DensAuction.tvc')
bid = ts4.core.load_code_cell('../build/DensBid.tvc')
rcod = ts4.core.load_code_cell('../build/DensRoot.tvc')

ts4.register_abi('DensPlatform')
ts4.register_abi('DensCertificate')
ts4.register_abi('DensAuction')
ts4.register_abi('DensBid')


class Root(ts4.BaseContract):
    def __init__(self):
        self.create_keypair()
        super(Root,
              self).__init__('DensRoot', {},
                             pubkey=self.public_key_,
                             private_key=self.private_key_,
                             nickname='Root',
                             override_address=ts4.Address('0:' + (64 * 'a')))
Exemple #2
0
import tonos_ts4.ts4 as ts4
import sys
import os
import time
import unittest

from Auction_test_base import AuctionTest

sys.path.append(os.environ['TEST4_PATH'] + '/ts4_py_lib')

s2b = ts4.str2bytes
b2s = ts4.bytes2str

# Set a directory where the artifacts of the used contracts are located
ts4.set_tests_path(os.environ['OUT_PATH'] + '/')

# Toggle to print additional execution info
ts4.set_verbose(True)


class AuctionTest_earlier_bid_wins(AuctionTest):
    def test_earlier_bid_wins(self):
        seed2 = 54
        (b2_pk, b2_pu) = ts4.make_keypair()

        bidder2 = ts4.BaseContract('TestAuctionBidder',
                                   dict(bid_key=b2_pu, seed=seed2),
                                   pubkey=b2_pu,
                                   private_key=b2_pk)
'''

    This script demonstrate how to exploit the droneContract smart contract.

'''

import tonos_ts4.ts4 as ts4

# Set a directory where the artifacts of the used contracts are located
ts4.set_tests_path('')

# Toggle to print additional execution info
ts4.set_verbose(False)

#Load the contract
dron = ts4.BaseContract('droneContract', {})


class dron(ts4.BaseContract):
    def __init__(self):
        self.create_keypair()
        # We pass a public key to the constructor that will identify the contract owner
        super(dron, self).__init__('droneContract', {},
                                   pubkey=self.public_key_)

    # Create a method to call setNumber without the owner's signature
    def setNumber(self, value, expect_ec=0):
        return self.call_method('setNumber', {'value': value},
                                expect_ec=expect_ec)

    # Create a method to call setNumber with the owner's signature