Exemple #1
0
    def test_abnormal_031_consensus(self):
        try:
            test_api.init()
            # ensure balance of wallet A is 1000
            balance_of_wallet_A = int(API.rpc().getbalance(
                test_config.ADDRESS_A)[1]["result"]["ont"])
            (process, response) = API.native().transfer_ont(
                test_config.ADDRESS_A, test_config.ADDRESS_B,
                str(balance_of_wallet_A - 1000), 0)
            API.node().wait_gen_block()

            (process,
             response) = API.native().approve_ont(test_config.ADDRESS_A,
                                                  test_config.ADDRESS_B,
                                                  "1000",
                                                  0,
                                                  sleep=0)
            (process,
             response) = API.native().approve_ont(test_config.ADDRESS_A,
                                                  test_config.ADDRESS_C,
                                                  "1000",
                                                  0,
                                                  sleep=0)
            API.node().wait_gen_block()

            balance_of_wallet_A = int(API.rpc().getbalance(
                test_config.ADDRESS_A)[1]["result"]["ont"])
            self.ASSERT(balance_of_wallet_A == 1000,
                        "wallet A balance changed")

            (process,
             responseb) = API.native().allowance_ont(test_config.ADDRESS_A,
                                                     test_config.ADDRESS_B, 0)
            # need to check
            #self.ASSERT(response["result"] == "00" , "allowance to wallet B is not 0")
            (process,
             responsec) = API.native().allowance_ont(test_config.ADDRESS_A,
                                                     test_config.ADDRESS_C, 0)
            # need to checkADDRESS_C
            #e803 == 1000 num
            self.ASSERT(
                responseb["result"]["Result"] == "e803"
                or responsec["result"]["Result"] == "e803",
                "allowance to wallet B/C is not 0")
        except Exception as e:
            logger.print(e.args[0])
Exemple #2
0
    def test_base_030_consensus(self):
        try:
            test_api.init()
            # ensure balance of wallet A is 1000
            balance_of_wallet_A1 = int(API.rpc().getbalance(
                test_config.ADDRESS_A)[1]["result"]["ont"])
            (process, response) = API.native().transfer_ont(
                test_config.ADDRESS_A, test_config.ADDRESS_B,
                str(balance_of_wallet_A1 - 1000), 0)

            balance_of_wallet_A1 = int(API.rpc().getbalance(
                test_config.ADDRESS_A)[1]["result"]["ont"])
            balance_of_wallet_B1 = int(API.rpc().getbalance(
                test_config.ADDRESS_B)[1]["result"]["ont"])
            balance_of_wallet_C1 = int(API.rpc().getbalance(
                test_config.ADDRESS_C)[1]["result"]["ont"])

            (process,
             response) = API.native().transfer_ont(test_config.ADDRESS_A,
                                                   test_config.ADDRESS_B,
                                                   "1000",
                                                   0,
                                                   sleep=0)
            (process,
             response) = API.native().transfer_ont(test_config.ADDRESS_A,
                                                   test_config.ADDRESS_C,
                                                   "1000",
                                                   0,
                                                   sleep=0)
            API.node().wait_gen_block()

            balance_of_wallet_A2 = int(API.rpc().getbalance(
                test_config.ADDRESS_A)[1]["result"]["ont"])
            balance_of_wallet_B2 = int(API.rpc().getbalance(
                test_config.ADDRESS_B)[1]["result"]["ont"])
            balance_of_wallet_C2 = int(API.rpc().getbalance(
                test_config.ADDRESS_C)[1]["result"]["ont"])
            self.ASSERT(balance_of_wallet_A2 == 0,
                        "wallet A balance changed[1]")
            self.ASSERT((balance_of_wallet_A1 + balance_of_wallet_B1 +
                         balance_of_wallet_C1) == (balance_of_wallet_A2 +
                                                   balance_of_wallet_B2 +
                                                   balance_of_wallet_C2),
                        "wallet A balance changed[2]")
        except Exception as e:
            logger.print(e.args[0])
Exemple #3
0
 def test_abnormal_025_consensus(self):
     try:
         test_api.init()
         m = 4
         pubkey_array = [
             test_config.PUBLIC_KEY_3, test_config.PUBLIC_KEY_4,
             test_config.PUBLIC_KEY_5, test_config.PUBLIC_KEY_6
         ]
         (process, response) = test_api.multi_sig_transfer(
             test_config.m_contract_addr,
             test_config.ADDRESS_A,
             test_config.ADDRESS_B,
             test_config.AMOUNT,
             m,
             pubkey_array,
             node_index=1)
         self.ASSERT(not process, "test_abnormal_025_consensus failed")
     except Exception as e:
         logger.print(e.args[0])
Exemple #4
0
 def test_init(self):
     test_api.init()