|
|
@@ -445,6 +445,28 @@ func TestUDPv5_lookup(t *testing.T) {
|
|
|
checkLookupResults(t, lookupTestnet, <-resultC)
|
|
|
}
|
|
|
|
|
|
+// This test checks the local node can be utilised to set key-values.
|
|
|
+func TestUDPv5_LocalNode(t *testing.T) {
|
|
|
+ t.Parallel()
|
|
|
+ var cfg Config
|
|
|
+ node := startLocalhostV5(t, cfg)
|
|
|
+ defer node.Close()
|
|
|
+ localNd := node.LocalNode()
|
|
|
+
|
|
|
+ // set value in node's local record
|
|
|
+ testVal := [4]byte{'A', 'B', 'C', 'D'}
|
|
|
+ localNd.Set(enr.WithEntry("testing", &testVal))
|
|
|
+
|
|
|
+ // retrieve the value from self to make sure it matches.
|
|
|
+ outputVal := [4]byte{}
|
|
|
+ if err := node.Self().Load(enr.WithEntry("testing", &outputVal)); err != nil {
|
|
|
+ t.Errorf("Could not load value from record: %v", err)
|
|
|
+ }
|
|
|
+ if testVal != outputVal {
|
|
|
+ t.Errorf("Wanted %#x to be retrieved from the record but instead got %#x", testVal, outputVal)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// udpV5Test is the framework for all tests above.
|
|
|
// It runs the UDPv5 transport on a virtual socket and allows testing outgoing packets.
|
|
|
type udpV5Test struct {
|