示例#1
0
def tester_channelmanager_library_address(
        deploy_key, tester_chain, tester_nettingchannel_library_address):
    return deploy_channelmanager_library(
        deploy_key,
        tester_chain,
        tester_nettingchannel_library_address,
    )
示例#2
0
    def __init__(self):
        super(NettingChannelStateMachine, self).__init__()

        deploy_key = sha3('deploy_key')
        gas_limit = 10**10

        self.private_keys = [
            sha3('p1'),
            sha3('p2'),
            sha3('p3'
                 ),  # third key used to generate signed but invalid transfers
        ]
        self.addresses = map(privatekey_to_address, self.private_keys)
        self.log = list()
        self.tester_state = tester_state(
            deploy_key,
            self.private_keys,
            gas_limit,
        )
        self.settle_timeout = 50
        self.token_amount = 1000

        self.tokens = [
            new_token(
                deploy_key,
                self.tester_state,
                self.token_amount,
                self.log.append,
            ),
            new_token(
                deploy_key,
                self.tester_state,
                self.token_amount,
                self.log.append,
            ),
        ]
        self.token = self.tokens[0]

        self.token_addresses = [token.address for token in self.tokens]

        self.nettingchannel_library_address = deploy_nettingchannel_library(
            deploy_key,
            self.tester_state,
        )
        self.channel_manager_library_address = deploy_channelmanager_library(
            deploy_key,
            self.tester_state,
            self.nettingchannel_library_address,
        )
        self.registry = new_registry(
            deploy_key,
            self.tester_state,
            self.channel_manager_library_address,
            self.log.append,
        )
        self.channelmanager = new_channelmanager(
            deploy_key,
            self.tester_state,
            self.log.append,
            self.registry,
            self.token.address,
        )
        self.netting_channel = new_nettingcontract(
            self.private_keys[0],
            self.private_keys[1],
            self.tester_state,
            self.log.append,
            self.channelmanager,
            self.settle_timeout,
        )

        address_and_balance = self.netting_channel.addressAndBalance(  # pylint: disable=no-member
            sender=self.private_keys[0], )

        self.closing_address = None
        self.update_transfer_called = False
        self.participant_addresses = {
            unhexlify(address_and_balance[0]),
            unhexlify(address_and_balance[2]),
        }

        self.channel_addresses = [
            unhexlify(self.netting_channel.address),
            make_address(),  # used to test invalid transfers
        ]