starting on propagation subprocess
This commit is contained in:
@@ -264,17 +264,7 @@ func TestClient_HiddenService(t *testing.T) {
|
||||
for _, v := range clients {
|
||||
go v.Start()
|
||||
}
|
||||
// quit := qu.T()
|
||||
// var wg sync.WaitGroup
|
||||
// go func() {
|
||||
// select {
|
||||
// case <-time.After(time.Second):
|
||||
// case <-quit:
|
||||
// return
|
||||
// }
|
||||
// quit.Q()
|
||||
// t.Error("SendExit test failed")
|
||||
// }()
|
||||
// Fund the client for all hops on all nodes.
|
||||
var wg sync.WaitGroup
|
||||
var counter atomic.Int32
|
||||
for i := 0; i < 25; i++ {
|
||||
@@ -294,7 +284,6 @@ func TestClient_HiddenService(t *testing.T) {
|
||||
log.D.F("%d %s %v", i, j, clients[0].SessionCache[j])
|
||||
}
|
||||
}
|
||||
// time.Sleep(time.Second / 2)
|
||||
for i := 0; i < 25; i++ {
|
||||
var identPrv *prv.Key
|
||||
if identPrv, e = prv.GenerateKey(); check(e) {
|
||||
@@ -302,18 +291,63 @@ func TestClient_HiddenService(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
identPub := pub.Derive(identPrv)
|
||||
// wg.Add(1)
|
||||
id := nonce.NewID()
|
||||
clients[0].SendIntro(id, clients[0].Sessions[i+returns],
|
||||
identPub, func(id nonce.ID, b slice.Bytes) {
|
||||
log.I.Ln("success")
|
||||
// wg.Done()
|
||||
})
|
||||
// wg.Wait()
|
||||
// time.Sleep(time.Second / 2)
|
||||
}
|
||||
time.Sleep(time.Second / 2)
|
||||
for _, v := range clients {
|
||||
v.Shutdown()
|
||||
}
|
||||
}
|
||||
func TestClient_HiddenServiceBroadcast(t *testing.T) {
|
||||
log2.SetLogLevel(log2.Trace)
|
||||
var clients []*Engine
|
||||
var e error
|
||||
const returns = 2
|
||||
if clients, e = CreateNMockCircuits(false, 5, returns); check(e) {
|
||||
t.Error(e)
|
||||
t.FailNow()
|
||||
}
|
||||
// Start up the clients.
|
||||
for _, v := range clients {
|
||||
go v.Start()
|
||||
}
|
||||
// Fund the client for all hops on all nodes.
|
||||
var wg sync.WaitGroup
|
||||
var counter atomic.Int32
|
||||
for i := 0; i < 25; i++ {
|
||||
log.D.Ln("buying sessions", i)
|
||||
wg.Add(1)
|
||||
counter.Inc()
|
||||
e = clients[0].BuyNewSessions(1000000, func() {
|
||||
wg.Done()
|
||||
counter.Dec()
|
||||
})
|
||||
if check(e) {
|
||||
wg.Done()
|
||||
counter.Dec()
|
||||
}
|
||||
wg.Wait()
|
||||
for j := range clients[0].SessionCache {
|
||||
log.D.F("%d %s %v", i, j, clients[0].SessionCache[j])
|
||||
}
|
||||
}
|
||||
var identPrv *prv.Key
|
||||
if identPrv, e = prv.GenerateKey(); check(e) {
|
||||
t.Error(e)
|
||||
t.FailNow()
|
||||
}
|
||||
identPub := pub.Derive(identPrv)
|
||||
id := nonce.NewID()
|
||||
clients[0].SendIntro(id, clients[0].Sessions[returns],
|
||||
identPub, func(id nonce.ID, b slice.Bytes) {
|
||||
log.I.Ln("success")
|
||||
})
|
||||
time.Sleep(time.Second * 5)
|
||||
for _, v := range clients {
|
||||
v.Shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,5 +12,6 @@ func (eng *Engine) hiddenservice(hs *hiddenservice.Layer, b slice.Bytes,
|
||||
log.D.F("%s adding introduction for key %x", eng.GetLocalNodeAddress(),
|
||||
hs.Identity.ToBytes())
|
||||
eng.Introductions.Add(hs.Identity.ToBytes(), b[*c:])
|
||||
log.I.Ln("stored new introduction")
|
||||
log.I.Ln("stored new introduction, starting broadcast")
|
||||
go eng.hiddenserviceBroadcaster()
|
||||
}
|
||||
|
||||
@@ -35,14 +35,13 @@ func (eng *Engine) handler() (out bool) {
|
||||
log.T.F("awaiting session keys for preimage %x session ID %x",
|
||||
p.Preimage, p.ID)
|
||||
}
|
||||
// For now if we received this we return true.
|
||||
// Later this will wait with a timeout on the lnd node returning the
|
||||
// success to trigger this.
|
||||
// For now if we received this we return true. Later this will wait with
|
||||
// a timeout on the lnd node returning the success to trigger this.
|
||||
p.ConfirmChan <- true
|
||||
case <-eng.Pause:
|
||||
log.D.Ln("pausing", eng.GetLocalNodeAddress())
|
||||
// For testing purposes we need to halt this handler and discard
|
||||
// channel messages.
|
||||
// For testing purposes we need to halt this handler and discard channel
|
||||
// messages.
|
||||
out:
|
||||
for {
|
||||
select {
|
||||
|
||||
11
pkg/relay/hiddenservice.go
Normal file
11
pkg/relay/hiddenservice.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package relay
|
||||
|
||||
func (eng *Engine) hiddenserviceBroadcaster() {
|
||||
log.D.Ln("propagating hidden service introduction")
|
||||
for {
|
||||
select {
|
||||
case <-eng.C.Wait():
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user