-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontract.py
30 lines (23 loc) · 963 Bytes
/
contract.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
import smartpy as sp
class BackboneContract(sp.Contract):
def __init__(self):
self.init(database = {})
@sp.entry_point
def add(self, params):
self.data.database[params.cert] = params.url
@sp.add_test(name = "BackboneContract")
def test():
creator = sp.test_account("Creator")
alice = sp.test_account("Alice")
bob = sp.test_account("Robert")
c1 = BackboneContract()
scenario = sp.test_scenario()
scenario.h1("Mini Kitties")
scenario += c1
def newKitty(cert, url):
return sp.record(cert = cert, url = url)
scenario += c1.add(newKitty("cert-1", "asd.abc.co")).run(sender = creator)
scenario += c1.add(newKitty("cert-2", "asd.asdasd.co")).run(sender = creator)
scenario += c1.add(newKitty("cert-3", "asd.ac.co")).run(sender = alice)
scenario += c1.add(newKitty("cert-4", "asd.co.in")).run(sender = bob)
sp.add_compilation_target("backbonecontract", BackboneContract())