def test_commit(self):
        with auction_contract.test_service():
            ## create transaction
            # init
            init_transaction = auction.init()
            token = init_transaction['transaction']['outputs'][0]

            # create auction
            auction_transaction = auction.create(
                (token, ), None, None, aggr_vk, t_commit, t_reveal, uid, v0,
                ov0)
            auction_object = auction_transaction['transaction']['outputs'][1]

            ## commit
            transaction = auction.commit(
                (auction_object, ),
                None,
                None,
                bidders[0][0],  # seq
                bidders[0][1],  # v
                bidders[0][2]  # sigma
            )

            ## submit transaction
            response = requests.post('http://127.0.0.1:5000/' +
                                     auction_contract.contract_name +
                                     '/commit',
                                     json=transaction_to_solution(transaction))
            self.assertTrue(response.json()['success'])
    def test_withdraw(self):
        with auction_contract.test_service():
            ## create transaction
            # init
            init_transaction = auction.init()
            token = init_transaction['transaction']['outputs'][0]

            # create auction
            auction_transaction = auction.create(
                (token, ), None, None, aggr_vk, t_commit, t_reveal, uid, v0,
                ov0)
            auction_object = auction_transaction['transaction']['outputs'][1]

            ## commit
            for i in range(len(bidders)):
                commit_transaction = auction.commit(
                    (auction_object, ),
                    None,
                    None,
                    bidders[i][0],  # seq
                    bidders[i][1],  # v
                    bidders[i][2]  # sigma
                )
                auction_object = commit_transaction['transaction']['outputs'][
                    0]

            ## reveal
            for i in range(len(bidders)):
                reveal_transaction = auction.reveal(
                    (auction_object, ),
                    None,
                    (dumps(bidders[i][1]), ),  # v
                    bidders[i][0],  # seq
                    bidders[i][2]  # sigma
                )
                auction_object = reveal_transaction['transaction']['outputs'][
                    0]

            ## withdraw
            transaction = auction.withdraw(
                (auction_object, ),
                None,
                (dumps(bidders[1][1]), pack(addr)),
                bidders[1][0],  # seq
                bidders[1][2]  # sigma
            )

            ## submit transaction
            response = requests.post('http://127.0.0.1:5000/' +
                                     auction_contract.contract_name +
                                     '/withdraw',
                                     json=transaction_to_solution(transaction))
            self.assertTrue(response.json()['success'])