From 6c2a324f1866740db927dd348796bb50ca5a63f3 Mon Sep 17 00:00:00 2001 From: Matthew Howard Date: Thu, 29 Aug 2024 13:53:27 +0100 Subject: [PATCH] add tests for the streamable macro functions --- tests/test_spend_bundle.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_spend_bundle.py b/tests/test_spend_bundle.py index 5e1c9e0f5..abe313b97 100644 --- a/tests/test_spend_bundle.py +++ b/tests/test_spend_bundle.py @@ -216,10 +216,28 @@ def test_spend_bundle( class NewAndImprovedSpendBundle(PySpendBundle): test_bool = True + def new_function(self) -> bool: + return self.test_bool + def test_derive_class(): + # Test if aggregate() supports class inheritance test = PySpendBundle.aggregate([]) assert isinstance(test, PySpendBundle) test = NewAndImprovedSpendBundle.aggregate([]) assert isinstance(test, NewAndImprovedSpendBundle) assert test.test_bool + assert test.new_function() + + # Test if the Streamable macro functions support class inheritance + obj_bytes = bytes(test) + test = NewAndImprovedSpendBundle.from_bytes(obj_bytes) + assert isinstance(test, NewAndImprovedSpendBundle) + assert test.test_bool + assert test.new_function() + + obj_json = test.to_json_dict() + test = NewAndImprovedSpendBundle.from_json_dict(obj_json) + assert isinstance(test, NewAndImprovedSpendBundle) + assert test.test_bool + assert test.new_function()