コード例 #1
0
    def test_from_raw(self):
        tx = MinterTx.from_raw(raw_tx=self.SIGNED_TX)

        self.assertEqual(tx.from_mx, self.TX.address)
        self.assertEqual(tx.address, self.TX.address)
        self.assertEqual(tx.pub_key, self.TX.pub_key)
        self.assertEqual(tx.commission, self.TX.commission)
        self.assertEqual(tx.coin, self.TX.coin)
        self.assertEqual(tx.stake, self.TX.stake)
コード例 #2
0
    def test_from_raw(self):
        tx = MinterTx.from_raw(raw_tx=self.SIGNED_TX)

        self.assertEqual(tx.from_mx, self.FROM)
        self.assertEqual(tx.name, self.TX.name)
        self.assertEqual(tx.symbol, self.TX.symbol)
        self.assertEqual(tx.initial_amount, self.TX.initial_amount)
        self.assertEqual(tx.initial_reserve, self.TX.initial_reserve)
        self.assertEqual(tx.crr, self.TX.crr)
        self.assertEqual(tx.max_supply, self.TX.max_supply)
コード例 #3
0
ファイル: guard.py プロジェクト: VitaliGreenberg/minter-guard
    def __init__(self,
                 api_urls,
                 pub_key,
                 set_off_tx,
                 missed_blocks=4,
                 sleep_time_ms=1000):
        """
        Args:
            api_urls (list): Minter API URLs
            pub_key (str): Pub key of validator under control
            set_off_tx (str): Signed tx, which will be sent to chain
            missed_blocks (int): Amount of missed blocks, when validator
                                 should be offed
            sleep_time_ms (int): Amount of milliseconds between guard eviction
        """
        super().__init__()

        # Set attributes
        self.minterapis = [MinterAPI(api_url) for api_url in api_urls]
        self.pub_key = pub_key
        self.set_off_tx = set_off_tx
        self.missed_blocks = int(missed_blocks)
        self.sleep_time_ms = int(sleep_time_ms)

        # Check set off tx to be valid
        tx = MinterTx.from_raw(self.set_off_tx)
        if not isinstance(tx, MinterSetCandidateOffTx):
            raise Exception(
                'Set off tx is not instance of MinterSetCandidateOffTx')

        # Get nonce from API
        nonce = None
        for minterapi in self.minterapis:
            try:
                nonce = minterapi.get_nonce(tx.from_mx)
                break
            except Exception as e:
                logger.error('{}: {}'.format(e.__class__.__name__,
                                             e.__str__()))

        if tx.nonce != nonce:
            raise Exception('Set off tx has {} nonce, expected {}'.format(
                tx.nonce, nonce))
コード例 #4
0
    def test_from_raw(self):
        tx = MinterTx.from_raw(raw_tx=self.SIGNED_TX)

        self.assertEqual(tx.from_mx, self.FROM)
コード例 #5
0
    def test_from_raw(self):
        tx = MinterTx.from_raw(raw_tx=self.SIGNED_TX)

        self.assertEqual(tx.pub_key, self.TX.pub_key)
        self.assertEqual(tx.coin, self.TX.coin)
        self.assertEqual(tx.value, self.TX.value)
コード例 #6
0
    def test_from_raw(self):
        tx = MinterTx.from_raw(raw_tx=self.SIGNED_TX)

        self.assertEqual(tx.check, self.TX.check)
        self.assertEqual(tx.proof, self.TX.proof)
コード例 #7
0
    def test_from_raw(self):
        tx = MinterTx.from_raw(raw_tx=self.SIGNED_TX)

        self.assertEqual(tx.pub_key, self.PUBLIC_KEY)
        self.assertEqual(tx.coin, self.TX.coin)
        self.assertEqual(tx.stake, self.TX.stake)
コード例 #8
0
 def sign_and_decode(self, payload):
     self.TX.payload = payload
     self.TX.sign(private_key=self.PK)
     self.TX_DECODED = MinterTx.from_raw(self.TX.signed_tx)