Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alex v committed Nov 25, 2024
1 parent 248b974 commit b72caad
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
4 changes: 1 addition & 3 deletions src/blsct/tokens/predicate_exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ bool ExecutePredicate(const ParsedPredicate& predicate, CCoinsViewCache& view, c
if (fDisconnect)
view.EraseToken(hash);
else {
blsct::TokenInfo info;
info = predicate.GetTokenInfo();
view.AddToken(hash, std::move(info));
view.AddToken(hash, blsct::TokenInfo{predicate.GetTokenInfo()});
}

return true;
Expand Down
26 changes: 13 additions & 13 deletions test/functional/blsct_nft.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def set_test_params(self):

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
self.log.info("Creating wallet1 with BLSCT")

Expand All @@ -29,8 +29,8 @@ def run_test(self):
#self.init_wallet(node=0, blsct=True)
self.nodes[0].createwallet(wallet_name="wallet1", blsct=True)
self.nodes[1].createwallet(wallet_name="wallet1", blsct=True)
wallet_info = self.nodes[0].get_wallet_rpc("wallet1")
wallet_info_2 = self.nodes[1].get_wallet_rpc("wallet1")
wallet = self.nodes[0].get_wallet_rpc("wallet1")
wallet_2 = self.nodes[1].get_wallet_rpc("wallet1")

self.log.info("Loading wallet1")

Expand All @@ -41,8 +41,8 @@ def run_test(self):
self.log.info("Generating BLSCT address")

# Generate a BLSCT address
blsct_address = wallet_info.getnewaddress(label="", address_type="blsct")
blsct_address_2 = wallet_info_2.getnewaddress(label="", address_type="blsct")
blsct_address = wallet.getnewaddress(label="", address_type="blsct")
blsct_address_2 = wallet_2.getnewaddress(label="", address_type="blsct")

self.log.info(f"BLSCT address NODE 1: {blsct_address}")
self.log.info(f"BLSCT address NODE 2: {blsct_address_2}")
Expand All @@ -54,14 +54,14 @@ def run_test(self):
self.log.info(f"Generated blocks: {len(block_hashes)}")

# Check the balance of the wallet
balance = wallet_info.getbalance()
balance = wallet.getbalance()
self.log.info(f"Balance in wallet1: {balance}")

assert_equal(len(block_hashes), 101)
assert balance > 0, "Balance should be greater than zero after mining"

self.log.info("Creating NFT collection and mining 1 block")
token = self.nodes[0].createnft({"name": "Test"}, 1000)
token = wallet.createnft({"name": "Test"}, 1000)
block_hashes = self.generatetoblsctaddress(self.nodes[0], 1, blsct_address)

tokens = self.nodes[0].listtokens()
Expand All @@ -74,7 +74,7 @@ def run_test(self):
assert tokens[0]['maxSupply'] == 1000, "incorrect max supply"
assert tokens[0]['mintedNft'] == {}, "incorrect current supply"

self.nodes[0].mintnft(token['tokenId'], 1, blsct_address, {"id": "null"})
wallet.mintnft(token['tokenId'], 1, blsct_address, {"id": "null"})
block_hashes = self.generatetoblsctaddress(self.nodes[0], 1, blsct_address)

tokenInfo = self.nodes[0].gettoken(token['tokenId'])
Expand All @@ -86,8 +86,8 @@ def run_test(self):

self.log.info(f"Minted 1 NFT")

nft_balance = self.nodes[0].getnftbalance(token['tokenId'])
nft_balance_2 = self.nodes[1].getnftbalance(token['tokenId'])
nft_balance = wallet.getnftbalance(token['tokenId'])
nft_balance_2 = wallet_2.getnftbalance(token['tokenId'])

self.log.info(f"Balance in NODE 1: {nft_balance}")
self.log.info(f"Balance in NODE 2: {nft_balance_2}")
Expand All @@ -97,11 +97,11 @@ def run_test(self):

self.log.info(f"Sending NFT with id #1 to NODE 2")

self.nodes[0].sendnfttoblsctaddress(token['tokenId'], 1, blsct_address_2)
wallet.sendnfttoblsctaddress(token['tokenId'], 1, blsct_address_2)
self.generatetoblsctaddress(self.nodes[0], 1, blsct_address)

nft_balance = self.nodes[0].getnftbalance(token['tokenId'])
nft_balance_2 = self.nodes[1].getnftbalance(token['tokenId'])
nft_balance = wallet.getnftbalance(token['tokenId'])
nft_balance_2 = wallet_2.getnftbalance(token['tokenId'])

self.log.info(f"Balance in NODE 1: {nft_balance}")
self.log.info(f"Balance in NODE 2: {nft_balance_2}")
Expand Down
26 changes: 13 additions & 13 deletions test/functional/blsct_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def set_test_params(self):

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
self.log.info("Creating wallet1 with BLSCT")

Expand All @@ -29,8 +29,8 @@ def run_test(self):
#self.init_wallet(node=0, blsct=True)
self.nodes[0].createwallet(wallet_name="wallet1", blsct=True)
self.nodes[1].createwallet(wallet_name="wallet1", blsct=True)
wallet_info = self.nodes[0].get_wallet_rpc("wallet1")
wallet_info_2 = self.nodes[1].get_wallet_rpc("wallet1")
wallet = self.nodes[0].get_wallet_rpc("wallet1")
wallet_2 = self.nodes[1].get_wallet_rpc("wallet1")

self.log.info("Loading wallet1")

Expand All @@ -41,8 +41,8 @@ def run_test(self):
self.log.info("Generating BLSCT address")

# Generate a BLSCT address
blsct_address = wallet_info.getnewaddress(label="", address_type="blsct")
blsct_address_2 = wallet_info_2.getnewaddress(label="", address_type="blsct")
blsct_address = wallet.getnewaddress(label="", address_type="blsct")
blsct_address_2 = wallet_2.getnewaddress(label="", address_type="blsct")

self.log.info(f"BLSCT address NODE 1: {blsct_address}")
self.log.info(f"BLSCT address NODE 2: {blsct_address_2}")
Expand All @@ -54,14 +54,14 @@ def run_test(self):
self.log.info(f"Generated blocks: {len(block_hashes)}")

# Check the balance of the wallet
balance = wallet_info.getbalance()
balance = wallet.getbalance()
self.log.info(f"Balance in wallet1: {balance}")

assert_equal(len(block_hashes), 101)
assert balance > 0, "Balance should be greater than zero after mining"

self.log.info("Creating token and mining 1 block")
token = self.nodes[0].createtoken({"name": "Test"}, 1000)
token = wallet.createtoken({"name": "Test"}, 1000)
block_hashes = self.generatetoblsctaddress(self.nodes[0], 1, blsct_address)

tokens = self.nodes[0].listtokens()
Expand All @@ -74,7 +74,7 @@ def run_test(self):
assert tokens[0]['maxSupply'] == 100000000000, "incorrect max supply"
assert tokens[0]['currentSupply'] == 0, "incorrect current supply"

self.nodes[0].minttoken(token['tokenId'], blsct_address, 1)
wallet.minttoken(token['tokenId'], blsct_address, 1)
block_hashes = self.generatetoblsctaddress(self.nodes[0], 1, blsct_address)

tokenInfo = self.nodes[0].gettoken(token['tokenId'])
Expand All @@ -86,8 +86,8 @@ def run_test(self):

self.log.info(f"Minted 1 token")

token_balance = self.nodes[0].gettokenbalance(token['tokenId'])
token_balance_2 = self.nodes[1].gettokenbalance(token['tokenId'])
token_balance = wallet.gettokenbalance(token['tokenId'])
token_balance_2 = wallet_2.gettokenbalance(token['tokenId'])

self.log.info(f"Balance in NODE 1: {token_balance}")
self.log.info(f"Balance in NODE 2: {token_balance_2}")
Expand All @@ -97,11 +97,11 @@ def run_test(self):

self.log.info(f"Sending 0.5 token to NODE 2")

self.nodes[0].sendtokentoblsctaddress(token['tokenId'], blsct_address_2, 0.5)
wallet.sendtokentoblsctaddress(token['tokenId'], blsct_address_2, 0.5)
self.generatetoblsctaddress(self.nodes[0], 2, blsct_address)

token_balance = self.nodes[0].gettokenbalance(token['tokenId'])
token_balance_2 = self.nodes[1].gettokenbalance(token['tokenId'])
token_balance = wallet.gettokenbalance(token['tokenId'])
token_balance_2 = wallet_2.gettokenbalance(token['tokenId'])

assert token_balance == 0.5, "incorrect token balance in node 1"
assert token_balance_2 == 0.5, "incorrect token balance in node 2"
Expand Down

0 comments on commit b72caad

Please sign in to comment.