-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtest_nft.py
82 lines (67 loc) · 2.99 KB
/
test_nft.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import unittest
from pprint import pprint
from peerplays import PeerPlays
from peerplaysbase.operationids import getOperationNameForId
from peerplays.instance import set_shared_peerplays_instance
from .fixtures import fixture_data, peerplays, core_unit
import random
import string
def get_random_string(length):
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str
class Testcases(unittest.TestCase):
def setUp(self):
# fixture_data()
self.nameMetadata = get_random_string(5)
self.nameNft = get_random_string(5)
# self.nameMetaData = "testmeta56"
# self.nameNft = "testnft56"
def test_nft(self):
print("============nft test begin=========")
self.setUp()
# peerplays.blocking = True
self.res = peerplays.nft_metadata_create("1.2.7",
self.nameMetadata,
self.nameMetadata,
self.nameMetadata,
revenue_partner="1.2.8",
revenue_split=300,
is_sellable=False,
is_transferable=False)
# peerplays.blocking = False
print("nft_metadata_create Success!")
self.metadataId = self.res["operation_results"][0][1]
print("metadataId:", self.metadataId)
peerplays.nft_metadata_update("1.2.7",
self.metadataId,
self.nameMetadata + "m",
self.nameMetadata + "m",
self.nameMetadata + "m",
"1.2.9",
400,
True,
True)
print("nft_metadata_update Success!")
self.res = peerplays.nft_mint("1.2.7",
self.metadataId,
"1.2.7",
"1.2.7",
"1.2.7",
self.nameNft)
print("nft_mint Success!")
self.tokenId = self.res["operation_results"][0][1]
peerplays.nft_safe_transfer_from("1.2.7",
"1.2.7",
"1.2.9",
self.tokenId,
"whatever")
print("nft_safe_transfer_from Success!")
peerplays.nft_approve("1.2.9", "1.2.8", self.tokenId)
print("nft_approve Success!")
peerplays.nft_set_approval_for_all("1.2.7", "1.2.10", True)
print("nft_set_approval_for_all Success!")
print("All tests successful!")
if __name__ == "__main__":
self = Testcases()
s = self