Exemplo n.º 1
0
    def test_dash_tx_sub_tx_close_account(self):
        tx = transaction.Transaction(SUB_TX_CLOSE_ACCOUNT)
        deser = tx.to_json()
        assert deser['version'] == 3
        assert deser['tx_type'] == 11
        extra_dict = deser['extra_payload']
        assert extra_dict == SUB_TX_CLOSE_ACCOUNT_D
        extra = tx.extra_payload
        assert (str(extra))
        assert extra.version == SUB_TX_CLOSE_ACCOUNT_D['version']
        assert len(extra.regTxHash) == 32
        assert extra.regTxHash == bfh(SUB_TX_CLOSE_ACCOUNT_D['regTxHash'])
        assert len(extra.hashPrevSubTx) == 32
        assert extra.hashPrevSubTx == \
            bfh(SUB_TX_CLOSE_ACCOUNT_D['hashPrevSubTx'])
        assert extra.creditFee == SUB_TX_CLOSE_ACCOUNT_D['creditFee']
        assert len(extra.payloadSig) == 96
        assert extra.payloadSig == bfh(SUB_TX_CLOSE_ACCOUNT_D['payloadSig'])
        ser = tx.serialize()
        assert ser == SUB_TX_CLOSE_ACCOUNT

        assert extra.to_hex_str() == SUB_TX_CLOSE_ACCOUNT[386:]
        extra2 = ProTxBase.from_hex_str(SPEC_SUB_TX_CLOSE_ACCOUNT,
                                        SUB_TX_CLOSE_ACCOUNT[386:])
        assert extra2.version == extra.version
        assert extra2.regTxHash == extra.regTxHash
        assert extra2.hashPrevSubTx == extra.hashPrevSubTx
        assert extra2.creditFee == extra.creditFee
        assert extra2.payloadSig == extra.payloadSig
Exemplo n.º 2
0
    def test_dash_tx_pro_up_rev_tx(self):
        tx = transaction.Transaction(PRO_UP_REV_TX)
        deser = tx.to_json()
        assert deser['version'] == 3
        assert deser['tx_type'] == 4
        extra_dict = deser['extra_payload']
        assert extra_dict == PRO_UP_REV_TX_D
        extra = tx.extra_payload
        assert (str(extra))
        assert extra.version == PRO_UP_REV_TX_D['version']
        assert len(extra.proTxHash) == 32
        assert extra.proTxHash == bfh(PRO_UP_REV_TX_D['proTxHash'])
        assert extra.reason == PRO_UP_REV_TX_D['reason']
        assert len(extra.inputsHash) == 32
        assert extra.inputsHash == bfh(PRO_UP_REV_TX_D['inputsHash'])
        assert len(extra.payloadSig) == 96
        assert extra.payloadSig == bfh(PRO_UP_REV_TX_D['payloadSig'])
        ser = tx.serialize()
        assert ser == PRO_UP_REV_TX

        assert extra.to_hex_str() == PRO_UP_REV_TX[384:]
        extra2 = ProTxBase.from_hex_str(SPEC_PRO_UP_REV_TX,
                                        PRO_UP_REV_TX[384:])
        assert extra2.version == extra.version
        assert extra2.proTxHash == extra.proTxHash
        assert extra2.reason == extra.reason
        assert extra2.inputsHash == extra.inputsHash
        assert extra2.payloadSig == extra.payloadSig
Exemplo n.º 3
0
    def test_dash_tx_sub_tx_reset_key(self):
        tx = transaction.Transaction(SUB_TX_RESET_KEY)
        deser = tx.to_json()
        assert deser['version'] == 3
        assert deser['tx_type'] == 10
        extra_dict = deser['extra_payload']
        assert extra_dict == SUB_TX_RESET_KEY_D
        extra = tx.extra_payload
        assert (str(extra))
        assert extra.version == SUB_TX_RESET_KEY_D['version']
        assert len(extra.regTxHash) == 32
        assert extra.regTxHash == bfh(SUB_TX_RESET_KEY_D['regTxHash'])
        assert len(extra.hashPrevSubTx) == 32
        assert extra.hashPrevSubTx == bfh(SUB_TX_RESET_KEY_D['hashPrevSubTx'])
        assert extra.creditFee == SUB_TX_RESET_KEY_D['creditFee']
        assert len(extra.newPubKey) == 48
        assert extra.newPubKey == bfh(SUB_TX_RESET_KEY_D['newPubKey'])
        assert len(extra.payloadSig) == 96
        assert extra.payloadSig == bfh(SUB_TX_RESET_KEY_D['payloadSig'])
        ser = tx.serialize()
        assert ser == SUB_TX_RESET_KEY

        assert extra.to_hex_str() == SUB_TX_RESET_KEY[386:]
        extra2 = ProTxBase.from_hex_str(SPEC_SUB_TX_RESET_KEY,
                                        SUB_TX_RESET_KEY[386:])
        assert extra2.version == extra.version
        assert extra2.regTxHash == extra.regTxHash
        assert extra2.hashPrevSubTx == extra.hashPrevSubTx
        assert extra2.creditFee == extra.creditFee
        assert extra2.newPubKey == extra.newPubKey
        assert extra2.payloadSig == extra.payloadSig
Exemplo n.º 4
0
    def test_dash_tx_sub_tx_register(self):
        tx = transaction.Transaction(SUB_TX_REGISTER)
        deser = tx.to_json()
        assert deser['version'] == 3
        assert deser['tx_type'] == 8
        extra_dict = deser['extra_payload']
        assert extra_dict == SUB_TX_REGISTER_D
        extra = tx.extra_payload
        assert (str(extra))
        assert extra.version == SUB_TX_REGISTER_D['version']
        assert extra.userName == SUB_TX_REGISTER_D['userName']
        assert len(extra.pubKey) == 48
        assert extra.pubKey == bfh(SUB_TX_REGISTER_D['pubKey'])
        assert len(extra.payloadSig) == 96
        assert extra.payloadSig == bfh(SUB_TX_REGISTER_D['payloadSig'])
        ser = tx.serialize()
        assert ser == SUB_TX_REGISTER

        assert extra.to_hex_str() == SUB_TX_REGISTER[386:]
        extra2 = ProTxBase.from_hex_str(SPEC_SUB_TX_REGISTER,
                                        SUB_TX_REGISTER[386:])
        assert extra2.version == extra.version
        assert extra2.userName == extra.userName
        assert extra2.pubKey == extra.pubKey
        assert extra2.payloadSig == extra.payloadSig
Exemplo n.º 5
0
    def test_dash_tx_pro_up_reg_tx(self):
        tx = transaction.Transaction(PRO_UP_REG_TX)
        deser = tx.to_json()
        assert deser['version'] == 3
        assert deser['tx_type'] == 3
        extra_dict = deser['extra_payload']
        assert extra_dict == PRO_UP_REG_TX_D
        extra = tx.extra_payload
        assert (str(extra))
        assert extra.version == PRO_UP_REG_TX_D['version']
        assert extra.proTxHash == bfh(PRO_UP_REG_TX_D['proTxHash'])
        assert extra.mode == PRO_UP_REG_TX_D['mode']
        assert len(extra.PubKeyOperator) == 48
        assert extra.PubKeyOperator == bfh(PRO_UP_REG_TX_D['PubKeyOperator'])
        assert len(extra.KeyIdVoting) == 20
        assert extra.KeyIdVoting == bfh(PRO_UP_REG_TX_D['KeyIdVoting'])
        assert extra.scriptPayout == bfh(PRO_UP_REG_TX_D['scriptPayout'])
        assert len(extra.inputsHash) == 32
        assert extra.inputsHash == bfh(PRO_UP_REG_TX_D['inputsHash'])
        assert extra.payloadSig == bfh(PRO_UP_REG_TX_D['payloadSig'])
        ser = tx.serialize()
        assert ser == PRO_UP_REG_TX

        assert extra.to_hex_str() == PRO_UP_REG_TX[384:]
        extra2 = ProTxBase.from_hex_str(SPEC_PRO_UP_REG_TX,
                                        PRO_UP_REG_TX[384:])
        assert extra2.version == extra.version
        assert extra2.proTxHash == extra.proTxHash
        assert extra2.mode == extra.mode
        assert extra2.PubKeyOperator == extra.PubKeyOperator
        assert extra2.KeyIdVoting == extra.KeyIdVoting
        assert extra2.scriptPayout == extra.scriptPayout
        assert extra2.inputsHash == extra.inputsHash
        assert extra2.payloadSig == extra.payloadSig
Exemplo n.º 6
0
    def test_dash_tx_pro_up_serv_tx(self):
        tx = transaction.Transaction(PRO_UP_SERV_TX)
        deser = tx.to_json()
        assert deser['version'] == 3
        assert deser['tx_type'] == 2
        extra_dict = deser['extra_payload']
        assert extra_dict == PRO_UP_SERV_TX_D
        extra = tx.extra_payload
        assert (str(extra))
        assert extra.version == PRO_UP_SERV_TX_D['version']
        assert len(extra.proTxHash) == 32
        assert extra.proTxHash == bfh(PRO_UP_SERV_TX_D['proTxHash'])
        assert extra.ipAddress == PRO_UP_SERV_TX_D['ipAddress']
        assert extra.port == PRO_UP_SERV_TX_D['port']
        assert extra.scriptOperatorPayout == \
            bfh(PRO_UP_SERV_TX_D['scriptOperatorPayout'])
        assert len(extra.inputsHash) == 32
        assert extra.inputsHash == bfh(PRO_UP_SERV_TX_D['inputsHash'])
        assert len(extra.payloadSig) == 96
        assert extra.payloadSig == bfh(PRO_UP_SERV_TX_D['payloadSig'])
        ser = tx.serialize()
        assert ser == PRO_UP_SERV_TX

        assert extra.to_hex_str() == PRO_UP_SERV_TX[386:]
        extra2 = ProTxBase.from_hex_str(SPEC_PRO_UP_SERV_TX,
                                        PRO_UP_SERV_TX[386:])
        assert extra2.version == extra.version
        assert extra2.proTxHash == extra.proTxHash
        assert extra2.ipAddress == extra.ipAddress
        assert extra2.port == extra.port
        assert extra2.scriptOperatorPayout == extra.scriptOperatorPayout
        assert extra2.inputsHash == extra.inputsHash
        assert extra2.payloadSig == extra.payloadSig
Exemplo n.º 7
0
 def test_dash_tx_v2(self):
     tx = transaction.Transaction(V2_TX)
     deser = tx.to_json()
     assert deser['version'] == 2
     assert deser['tx_type'] == 0
     assert deser['extra_payload'] == ''
     assert tx.extra_payload == b''
     ser = tx.serialize()
     assert ser == V2_TX
Exemplo n.º 8
0
 def test_dash_tx_wrong_spec_tx(self):
     tx = transaction.Transaction(WRONG_SPEC_TX)
     deser = tx.to_json()
     assert deser['version'] == 12255234
     assert deser['tx_type'] == 0
     extra_dict = deser['extra_payload']
     assert extra_dict == ''
     extra = tx.extra_payload
     assert extra == b''
     ser = tx.serialize()
     assert ser == WRONG_SPEC_TX
Exemplo n.º 9
0
    def test_dash_tx_pro_reg_tx(self):
        tx = transaction.Transaction(PRO_REG_TX)
        deser = tx.to_json()
        assert deser['version'] == 3
        assert deser['tx_type'] == 1
        extra_dict = deser['extra_payload']
        assert extra_dict == PRO_REG_TX_D
        extra = tx.extra_payload
        assert (str(extra))
        assert extra.version == PRO_REG_TX_D['version']
        assert extra.type == PRO_REG_TX_D['type']
        assert extra.mode == PRO_REG_TX_D['mode']
        assert len(extra.collateralOutpoint.hash) == 32
        assert extra.collateralOutpoint.hash == \
            bfh(PRO_REG_TX_D['collateralOutpoint']['hash'])[::-1]
        assert extra.collateralOutpoint.index == \
            PRO_REG_TX_D['collateralOutpoint']['index']
        assert extra.ipAddress == PRO_REG_TX_D['ipAddress']
        assert extra.port == PRO_REG_TX_D['port']
        assert len(extra.KeyIdOwner) == 20
        assert extra.KeyIdOwner == bfh(PRO_REG_TX_D['KeyIdOwner'])
        assert len(extra.PubKeyOperator) == 48
        assert extra.PubKeyOperator == bfh(PRO_REG_TX_D['PubKeyOperator'])
        assert len(extra.KeyIdVoting) == 20
        assert extra.KeyIdVoting == bfh(PRO_REG_TX_D['KeyIdVoting'])
        assert extra.operatorReward == PRO_REG_TX_D['operatorReward']
        assert extra.scriptPayout == bfh(PRO_REG_TX_D['scriptPayout'])
        assert len(extra.inputsHash) == 32
        assert extra.inputsHash == bfh(PRO_REG_TX_D['inputsHash'])
        assert extra.payloadSig == bfh(PRO_REG_TX_D['payloadSig'])
        ser = tx.serialize()
        assert ser == PRO_REG_TX

        assert extra.to_hex_str() == PRO_REG_TX[980:]
        extra2 = ProTxBase.from_hex_str(SPEC_PRO_REG_TX, PRO_REG_TX[980:])
        assert extra2.version == extra.version
        assert extra2.type == extra.type
        assert extra2.mode == extra.mode
        assert extra2.collateralOutpoint.hash == extra.collateralOutpoint.hash
        assert extra2.collateralOutpoint.index == \
            extra.collateralOutpoint.index
        assert extra2.ipAddress == extra.ipAddress
        assert extra2.port == extra.port
        assert extra2.KeyIdOwner == extra.KeyIdOwner
        assert extra2.PubKeyOperator == extra.PubKeyOperator
        assert extra2.KeyIdVoting == extra.KeyIdVoting
        assert extra2.operatorReward == extra.operatorReward
        assert extra2.scriptPayout == extra.scriptPayout
        assert extra2.inputsHash == extra.inputsHash
        assert extra2.payloadSig == extra.payloadSig
Exemplo n.º 10
0
    def test_dash_tx_sub_tx_topup(self):
        tx = transaction.Transaction(SUB_TX_TOPUP)
        deser = tx.to_json()
        assert deser['version'] == 3
        assert deser['tx_type'] == 9
        extra_dict = deser['extra_payload']
        assert extra_dict == SUB_TX_TOPUP_D
        extra = tx.extra_payload
        assert (str(extra))
        assert extra.version == SUB_TX_TOPUP_D['version']
        assert len(extra.regTxHash) == 32
        assert extra.regTxHash == bfh(SUB_TX_TOPUP_D['regTxHash'])
        ser = tx.serialize()
        assert ser == SUB_TX_TOPUP

        assert extra.to_hex_str() == SUB_TX_TOPUP[386:]
        extra2 = ProTxBase.from_hex_str(SPEC_SUB_TX_TOPUP, SUB_TX_TOPUP[386:])
        assert extra2.version == extra.version
        assert extra2.regTxHash == extra.regTxHash
Exemplo n.º 11
0
    def test_dash_tx_cb_tx(self):
        tx = transaction.Transaction(CB_TX)
        deser = tx.to_json()
        assert deser['version'] == 3
        assert deser['tx_type'] == 5
        extra_dict = deser['extra_payload']
        assert extra_dict == CB_TX_D
        extra = tx.extra_payload
        assert (str(extra))
        assert extra.version == CB_TX_D['version']
        assert extra.height == CB_TX_D['height']
        assert len(extra.merkleRootMNList) == 32
        assert extra.merkleRootMNList == bfh(CB_TX_D['merkleRootMNList'])
        ser = tx.serialize()
        assert ser == CB_TX

        assert extra.to_hex_str() == CB_TX[532:]
        extra2 = ProTxBase.from_hex_str(SPEC_CB_TX, CB_TX[532:])
        assert extra2.version == extra.version
        assert extra2.height == extra.height
        assert extra2.merkleRootMNList == extra.merkleRootMNList
Exemplo n.º 12
0
 def test_dash_tx_unknown_spec_tx(self):
     tx = transaction.Transaction(UNKNOWN_SPEC_TX)
     with self.assertRaises(DashTxError):
         tx.to_json()