Don't use network for sending ACK #2205

Merged
PeterSurda merged 6 commits from gitea-77 into v0.6 2024-04-05 01:15:06 +02:00
Showing only changes of commit 2030e08db3 - Show all commits

View File

@ -2,11 +2,18 @@
import sys import sys
import time import time
from binascii import hexlify, unhexlify
from struct import pack
from six.moves import queue, xmlrpc_client from six.moves import queue, xmlrpc_client
from pybitmessage import protocol
from pybitmessage.defaults import (
networkDefaultProofOfWorkNonceTrialsPerByte,
networkDefaultPayloadLengthExtraBytes)
from .partial import TestPartialRun from .partial import TestPartialRun
from .samples import sample_statusbar_msg # any from .samples import sample_statusbar_msg, sample_object_data
class TestAPIThread(TestPartialRun): class TestAPIThread(TestPartialRun):
@ -66,3 +73,22 @@ class TestAPIThread(TestPartialRun):
if sys.hexversion >= 0x3000000: if sys.hexversion >= 0x3000000:
self.assertEqual(status["networkConnections"], 4) self.assertEqual(status["networkConnections"], 4)
self.assertEqual(status["pendingDownload"], 0) self.assertEqual(status["pendingDownload"], 0)
def test_disseminate_preencrypted(self):
"""Call disseminatePreEncryptedMsg API command and check inventory"""
import proofofwork
from inventory import Inventory
proofofwork.init()
update_object = pack(
'>Q', int(time.time() + 7200)) + sample_object_data[16:]
invhash = unhexlify(self.api.disseminatePreEncryptedMsg(
hexlify(update_object).decode(),
networkDefaultProofOfWorkNonceTrialsPerByte,
networkDefaultPayloadLengthExtraBytes
))
obj_type, obj_stream, obj_data = Inventory()[invhash][:3]
self.assertEqual(obj_type, 42)
self.assertEqual(obj_stream, 2)
self.assertEqual(sample_object_data[16:], obj_data[16:])
self.assertTrue(protocol.isProofOfWorkSufficient(obj_data))