plugin tests: actually check log result + move over to '' -> true

a few things. one is that `is_in_log` returns a result rather than
enforcing a condition. so these lines all need asserts

two is that with the 'allow_deprecated_apis' option on, the python json
parser overwrites the now typed input with the later-added string
version, so the only option value present in the option key-value set is
the last, string one. the check for this has been updated to only verify
that the string version is included (i manually verified that both are
printed to the JSON message)
This commit is contained in:
lisa neigut
2020-03-11 15:35:16 -05:00
committed by Rusty Russell
parent af7e879308
commit a08905c344

View File

@@ -58,9 +58,9 @@ def test_option_types(node_factory):
'bool_opt': True, 'bool_opt': True,
}) })
n.daemon.is_in_log(r"option str_opt ok <class 'str'>") assert n.daemon.is_in_log(r"option str_opt ok <class 'str'>")
n.daemon.is_in_log(r"option int_opt 22 <class 'int'>") assert n.daemon.is_in_log(r"option int_opt 22 <class 'int'>")
n.daemon.is_in_log(r"option bool_opt True <class 'bool'>") assert n.daemon.is_in_log(r"option bool_opt True <class 'bool'>")
n.stop() n.stop()
# A blank bool_opt should default to false # A blank bool_opt should default to false
@@ -70,7 +70,7 @@ def test_option_types(node_factory):
'bool_opt': '', 'bool_opt': '',
}) })
n.daemon.is_in_log(r"option bool_opt False <class 'bool'>") assert n.daemon.is_in_log(r"option bool_opt True <class 'bool'>")
n.stop() n.stop()
# What happens if we give it a bad bool-option? # What happens if we give it a bad bool-option?
@@ -103,13 +103,15 @@ def test_option_types(node_factory):
'str_opt': 'ok', 'str_opt': 'ok',
'int_opt': 22, 'int_opt': 22,
'bool_opt': 1, 'bool_opt': 1,
'allow-deprecated-apis': True
}) })
n.daemon.is_in_log(r"option str_opt ok <class 'str'>") # because of how the python json parser works, since we're adding the deprecated
n.daemon.is_in_log(r"option int_opt 22 <class 'int'>") # string option after the 'typed' option in the JSON, the string option overwrites
n.daemon.is_in_log(r"option int_opt 22 <class 'str'>") # the earlier typed option in JSON parsing, resulting in a option set of only strings
n.daemon.is_in_log(r"option bool_opt True <class 'bool'>") assert n.daemon.is_in_log(r"option str_opt ok <class 'str'>")
n.daemon.is_in_log(r"option bool_opt true <class 'str'>") assert n.daemon.is_in_log(r"option int_opt 22 <class 'str'>")
assert n.daemon.is_in_log(r"option bool_opt 1 <class 'str'>")
n.stop() n.stop()