mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 10:31:35 +00:00
Fix comment out unused functionalities and add LND 0.17.2 to tests
This commit is contained in:
parent
366283488a
commit
69537d4c00
6
.github/workflows/integration-tests.yml
vendored
6
.github/workflows/integration-tests.yml
vendored
@ -18,12 +18,12 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
max-parallel: 4
|
max-parallel: 2
|
||||||
matrix:
|
matrix:
|
||||||
python-tag: ['3.11.6-slim-bookworm', '3.12-slim-bookworm']
|
python-tag: ['3.11.6-slim-bookworm', '3.12-slim-bookworm']
|
||||||
lnd-version: ['v0.17.0-beta'] # , 'v0.17.0-beta.rc1']
|
lnd-version: ['v0.17.0-beta', 'v0.17.2-beta.rc1']
|
||||||
cln-version: ['v23.08.1']
|
cln-version: ['v23.08.1']
|
||||||
ln-vendor: ['LND', 'CLN']
|
ln-vendor: ['LND'] #, 'CLN']
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 'Checkout'
|
- name: 'Checkout'
|
||||||
|
@ -362,12 +362,13 @@ class LNDNode:
|
|||||||
|
|
||||||
return status, expiry_height
|
return status, expiry_height
|
||||||
|
|
||||||
@classmethod
|
# UNUSED
|
||||||
def resetmc(cls):
|
# @classmethod
|
||||||
routerstub = router_pb2_grpc.RouterStub(cls.channel)
|
# def resetmc(cls):
|
||||||
request = router_pb2.ResetMissionControlRequest()
|
# routerstub = router_pb2_grpc.RouterStub(cls.channel)
|
||||||
_ = routerstub.ResetMissionControl(request)
|
# request = router_pb2.ResetMissionControlRequest()
|
||||||
return True
|
# _ = routerstub.ResetMissionControl(request)
|
||||||
|
# return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate_ln_invoice(cls, invoice, num_satoshis, routing_budget_ppm):
|
def validate_ln_invoice(cls, invoice, num_satoshis, routing_budget_ppm):
|
||||||
|
@ -34,21 +34,23 @@ class NickGenerator:
|
|||||||
from .dicts.en.adjectives import adjectives
|
from .dicts.en.adjectives import adjectives
|
||||||
from .dicts.en.adverbs import adverbs
|
from .dicts.en.adverbs import adverbs
|
||||||
from .dicts.en.nouns import nouns
|
from .dicts.en.nouns import nouns
|
||||||
elif lang == "Spanish":
|
|
||||||
from .dicts.es.adjectives import adjectives
|
|
||||||
from .dicts.es.adverbs import adverbs
|
|
||||||
from .dicts.es.nouns import nouns
|
|
||||||
else:
|
|
||||||
raise ValueError("Language not implemented.")
|
|
||||||
|
|
||||||
if verbose:
|
# UNUSED
|
||||||
print(
|
# elif lang == "Spanish":
|
||||||
f"{lang} SHA256 Nick Generator initialized with:"
|
# from .dicts.es.adjectives import adjectives
|
||||||
+ f"\nUp to {len(adverbs)} adverbs."
|
# from .dicts.es.adverbs import adverbs
|
||||||
+ f"\nUp to {len(adjectives)} adjectives."
|
# from .dicts.es.nouns import nouns
|
||||||
+ f"\nUp to {len(nouns)} nouns."
|
# else:
|
||||||
+ f"\nUp to {max_num+1} numerics.\n"
|
# raise ValueError("Language not implemented.")
|
||||||
)
|
# UNUSED
|
||||||
|
# if verbose:
|
||||||
|
# print(
|
||||||
|
# f"{lang} SHA256 Nick Generator initialized with:"
|
||||||
|
# + f"\nUp to {len(adverbs)} adverbs."
|
||||||
|
# + f"\nUp to {len(adjectives)} adjectives."
|
||||||
|
# + f"\nUp to {len(nouns)} nouns."
|
||||||
|
# + f"\nUp to {max_num+1} numerics.\n"
|
||||||
|
# )
|
||||||
|
|
||||||
self.use_adv = use_adv
|
self.use_adv = use_adv
|
||||||
self.use_adj = use_adj
|
self.use_adj = use_adj
|
||||||
@ -84,11 +86,13 @@ class NickGenerator:
|
|||||||
|
|
||||||
# Compute adverb id
|
# Compute adverb id
|
||||||
if self.use_adv:
|
if self.use_adv:
|
||||||
adv_id = int(nick_id / (self.max_num * num_nouns * num_adj))
|
pass
|
||||||
adv = self.adverbs[adv_id]
|
# UNUSED
|
||||||
remainder = nick_id - adv_id * self.max_num * num_nouns * num_adj
|
# adv_id = int(nick_id / (self.max_num * num_nouns * num_adj))
|
||||||
if self.verbose:
|
# adv = self.adverbs[adv_id]
|
||||||
print(f"Adverb: {adv}, id {adv_id}.")
|
# remainder = nick_id - adv_id * self.max_num * num_nouns * num_adj
|
||||||
|
# if self.verbose:
|
||||||
|
# print(f"Adverb: {adv}, id {adv_id}.")
|
||||||
else:
|
else:
|
||||||
adv_id, adv, remainder = 0, "", nick_id
|
adv_id, adv, remainder = 0, "", nick_id
|
||||||
|
|
||||||
@ -154,69 +158,71 @@ class NickGenerator:
|
|||||||
nick pool diversity due to max_lenght
|
nick pool diversity due to max_lenght
|
||||||
restrictions.
|
restrictions.
|
||||||
"""
|
"""
|
||||||
|
return
|
||||||
|
# UNUSED
|
||||||
|
# import random
|
||||||
|
# import statistics
|
||||||
|
|
||||||
import random
|
# attempts = []
|
||||||
import statistics
|
# for i in range(num_runs):
|
||||||
|
# string = str(random.uniform(0, 1_000_000))
|
||||||
|
# hash = hashlib.sha256(str.encode(string)).hexdigest()
|
||||||
|
|
||||||
attempts = []
|
# _, _, pool_size, tries = self.short_from_SHA256(hash, max_length)
|
||||||
for i in range(num_runs):
|
# attempts.append(tries)
|
||||||
string = str(random.uniform(0, 1_000_000))
|
|
||||||
hash = hashlib.sha256(str.encode(string)).hexdigest()
|
|
||||||
|
|
||||||
_, _, pool_size, tries = self.short_from_SHA256(hash, max_length)
|
# median = statistics.median(attempts)
|
||||||
attempts.append(tries)
|
# mean = statistics.mean(attempts)
|
||||||
|
|
||||||
median = statistics.median(attempts)
|
# print(f"\nFor max_length of {max_length}:")
|
||||||
mean = statistics.mean(attempts)
|
# print(f"Median loss of entropy factor is {median}.")
|
||||||
|
# print(f"Mean loss of entropy factor is {mean}.")
|
||||||
print(f"\nFor max_length of {max_length}:")
|
# print(
|
||||||
print(f"Median loss of entropy factor is {median}.")
|
# f"Approximate real pool is {human_format( int(pool_size/(mean+1)))} nicks in size."
|
||||||
print(f"Mean loss of entropy factor is {mean}.")
|
# )
|
||||||
print(
|
|
||||||
f"Approximate real pool is {human_format( int(pool_size/(mean+1)))} nicks in size."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
# UNUSED
|
||||||
# Just for code timming
|
# if __name__ == "__main__":
|
||||||
t0 = time.time()
|
# # Just for code timming
|
||||||
|
# t0 = time.time()
|
||||||
|
|
||||||
# Hardcoded example text and hashing
|
# # Hardcoded example text and hashing
|
||||||
nick_lang = "English" # Spanish
|
# nick_lang = "English" # Spanish
|
||||||
hash = hashlib.sha256(b"No one expected such cool nick!!").hexdigest()
|
# hash = hashlib.sha256(b"No one expected such cool nick!!").hexdigest()
|
||||||
max_length = 22
|
# max_length = 22
|
||||||
max_iter = 100_000_000
|
# max_iter = 100_000_000
|
||||||
|
|
||||||
# Initialized nick generator
|
# # Initialized nick generator
|
||||||
GenNick = NickGenerator(lang=nick_lang)
|
# GenNick = NickGenerator(lang=nick_lang)
|
||||||
|
|
||||||
# Generates a short nick with length limit from SHA256
|
# # Generates a short nick with length limit from SHA256
|
||||||
nick, nick_id, pool_size, iterations = GenNick.short_from_SHA256(
|
# nick, nick_id, pool_size, iterations = GenNick.short_from_SHA256(
|
||||||
hash, max_length, max_iter
|
# hash, max_length, max_iter
|
||||||
)
|
# )
|
||||||
|
|
||||||
# Output
|
# # Output
|
||||||
print(
|
# print(
|
||||||
f"Nick number {nick_id} has been selected among"
|
# f"Nick number {nick_id} has been selected among"
|
||||||
+ f" {human_format(pool_size)} possible nicks.\n"
|
# + f" {human_format(pool_size)} possible nicks.\n"
|
||||||
+ f"Needed {iterations} iterations to find one "
|
# + f"Needed {iterations} iterations to find one "
|
||||||
+ f"this short.\nYour nick is {nick} !\n"
|
# + f"this short.\nYour nick is {nick} !\n"
|
||||||
)
|
# )
|
||||||
print(f"Nick lenght is {len(nick)} characters.")
|
# print(f"Nick lenght is {len(nick)} characters.")
|
||||||
print(f"Nick landed at height {nick_id/(pool_size+1)} on the pool.")
|
# print(f"Nick landed at height {nick_id/(pool_size+1)} on the pool.")
|
||||||
print(f"Took {time.time()-t0} secs.\n")
|
# print(f"Took {time.time()-t0} secs.\n")
|
||||||
|
|
||||||
# Print many nicks
|
# # Print many nicks
|
||||||
import random
|
# import random
|
||||||
|
|
||||||
random.seed(1)
|
# random.seed(1)
|
||||||
|
|
||||||
for i in range(100):
|
# for i in range(100):
|
||||||
string = str(random.uniform(0, 1_000_000))
|
# string = str(random.uniform(0, 1_000_000))
|
||||||
hash = hashlib.sha256(str.encode(string)).hexdigest()
|
# hash = hashlib.sha256(str.encode(string)).hexdigest()
|
||||||
print(
|
# print(
|
||||||
GenNick.short_from_SHA256(hash, max_length=max_length, max_iter=max_iter)[0]
|
# GenNick.short_from_SHA256(hash, max_length=max_length, max_iter=max_iter)[0]
|
||||||
)
|
# )
|
||||||
|
|
||||||
# Other analysis
|
# # Other analysis
|
||||||
GenNick.compute_pool_size_loss(max_length, max_iter, 200)
|
# GenNick.compute_pool_size_loss(max_length, max_iter, 200)
|
||||||
|
Loading…
Reference in New Issue
Block a user