def inputPostFormatter(post): """ Formats the input of a whisper post and converts all values to HEX """ post["ttl"] = from_decimal(post["ttl"]) post["workToProve"] = from_decimal(post.get("workToProve", 0)) post["priority"] = from_decimal(post["priority"]) if not is_array(post.get("topics")): post["topics"] = [post["topics"]] if post.get("topics") else [] post["topics"] = [topic if is_0x_prefixed(topic) else encode_hex(topic) for topic in post["topics"]] return post
def inputPostFormatter(post): """ Formats the input of a whisper post and converts all values to HEX """ post["ttl"] = from_decimal(post["ttl"]) post["workToProve"] = from_decimal(post.get("workToProve", 0)) post["priority"] = from_decimal(post["priority"]) if not is_list_like(post.get("topics")): post["topics"] = [post["topics"]] if post.get("topics") else [] post["topics"] = [ topic if is_0x_prefixed(topic) else encode_hex(topic) for topic in post["topics"] ] return post
def test_conversion_rount_trip(value): intermediate_value = from_decimal(value) result_value = to_decimal(intermediate_value) error_msg = "Expected: {0!r}, Result: {1!r}, Intermediate: {2!r}".format( value, result_value, intermediate_value, ) assert result_value == value, error_msg
def inputTransactionFormatter(options): """ Formats the input of a transaction and converts all values to HEX """ options.setdefault("from", config.defaultAccount) options["from"] = inputAddressFormatter(options["from"]) if options.get("to"): options["to"] = inputAddressFormatter(options["to"]) for key in ("gasPrice", "gas", "value", "nonce"): if key in options: options[key] = from_decimal(options[key]) return options
def test_from_decimal(value, expected): assert from_decimal(value) == expected
def fromDecimal(decimal): return from_decimal(decimal)
def test_conversion_rount_trip(value): intermediate_value = from_decimal(value) result_value = to_decimal(intermediate_value) assert result_value == value, "Expected: {0!r}, Result: {1!r}, Intermediate: {2!r}".format(value, result_value, intermediate_value)
def test_conversion_rount_trip(value): intermediate_value = from_decimal(value) result_value = to_decimal(intermediate_value) assert result_value == value