Example #1
0
    def test_remove_transfer_token_metadata(self):
        alice_xmss = get_alice_xmss()
        bob_xmss = get_bob_xmss()

        token_transaction = get_token_transaction(alice_xmss, bob_xmss)
        TokenMetadata.create_token_metadata(self.state, token_transaction,
                                            None)

        transfer_token = TransferTokenTransaction.create(
            token_txhash=token_transaction.txhash,
            addrs_to=[alice_xmss.address],
            amounts=[100000000],
            fee=1,
            xmss_pk=bob_xmss.pk)
        transfer_token.sign(alice_xmss)

        TokenMetadata.update_token_metadata(self.state, transfer_token, None)
        token_metadata = TokenMetadata.get_token_metadata(
            self.state, transfer_token.token_txhash)
        self.assertIn(transfer_token.txhash,
                      token_metadata.transfer_token_tx_hashes)

        TokenMetadata.remove_transfer_token_metadata(self.state,
                                                     transfer_token, None)
        token_metadata = TokenMetadata.get_token_metadata(
            self.state, transfer_token.token_txhash)
        self.assertNotIn(transfer_token.txhash,
                         token_metadata.transfer_token_tx_hashes)
Example #2
0
    def test_remove_token_metadata(self):
        alice_xmss = get_alice_xmss()
        bob_xmss = get_bob_xmss()

        token_tx = get_token_transaction(alice_xmss, bob_xmss)
        TokenMetadata.create_token_metadata(self.state, token_tx, None)

        token_metadata = TokenMetadata.get_token_metadata(
            self.state, token_tx.txhash)
        self.assertEqual(token_metadata.token_txhash, token_tx.txhash)
        TokenMetadata.remove_token_metadata(self.state, token_tx, None)
        self.assertIsNone(
            TokenMetadata.get_token_metadata(self.state, token_tx.txhash))
Example #3
0
 def test_get_token_metadata(self):
     token_txhash = bytes(sha2_256(b'alpha'))
     token_metadata = TokenMetadata.create(
         token_txhash,
         [bytes(sha2_256(b'delta')),
          bytes(sha2_256(b'gamma'))])
     self.state._db.get_raw = MagicMock(
         return_value=token_metadata.serialize())
     self.assertEqual(
         TokenMetadata.get_token_metadata(self.state,
                                          token_txhash).to_json(),
         token_metadata.to_json())
Example #4
0
    def test_create_token_metadata(self):
        alice_xmss = get_alice_xmss()
        bob_xmss = get_bob_xmss()

        token_transaction = get_token_transaction(alice_xmss, bob_xmss)
        TokenMetadata.create_token_metadata(self.state, token_transaction,
                                            None)

        token_metadata = TokenMetadata.get_token_metadata(
            self.state, token_transaction.txhash)
        self.assertEqual(token_metadata.token_txhash, token_transaction.txhash)
        self.assertEqual(token_metadata.transfer_token_tx_hashes[0],
                         token_transaction.txhash)