Skip to content

Commit 713cad9

Browse files
ADD. adding a nested Nativescript test case before attempting to improve readability of NativeScript.from_dict() class method
1 parent a6f5485 commit 713cad9

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/pycardano/test_nativescript.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,43 @@ def test_from_dict():
196196

197197
assert script_from_dict == script_all
198198
assert script_from_dict.to_dict() == script_all_dict
199+
200+
201+
def test_from_dict_nested_scripts():
202+
vk1 = VerificationKey.from_cbor(
203+
"58206443a101bdb948366fc87369336224595d36d8b0eee5602cba8b81a024e58473"
204+
)
205+
vk2 = VerificationKey.from_cbor(
206+
"58206443a101bdb948366fc87369336224595d36d8b0eee5602cba8b81a024e58475"
207+
)
208+
spk1 = ScriptPubkey(key_hash=vk1.hash())
209+
spk2 = ScriptPubkey(key_hash=vk2.hash())
210+
before = InvalidHereAfter(3000)
211+
212+
script_all = ScriptAll([before, spk2])
213+
script_any = ScriptAny([spk1, script_all])
214+
215+
nested_script_dict = {
216+
"type": "any",
217+
"scripts": [
218+
{
219+
"type": "sig",
220+
"keyHash": "9139e5c0a42f0f2389634c3dd18dc621f5594c5ba825d9a8883c6627",
221+
},
222+
{
223+
"type": "all",
224+
"scripts": [
225+
{"type": "before", "slot": 3000},
226+
{
227+
"type": "sig",
228+
"keyHash": "835600a2be276a18a4bebf0225d728f090f724f4c0acd591d066fa6f",
229+
},
230+
],
231+
},
232+
],
233+
}
234+
235+
script_from_dict = NativeScript.from_dict(nested_script_dict)
236+
237+
assert script_from_dict == script_any
238+
assert script_from_dict.to_dict() == nested_script_dict

0 commit comments

Comments
 (0)