MCPcopy Create free account
hub / github.com/encodeous/nylon / TestBundleUnbundle

Function TestBundleUnbundle

state/distribution_test.go:17–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestBundleUnbundle(t *testing.T) {
18 root := GenerateKey()
19 cfg := CentralCfg{
20 Dist: nil,
21 Routers: make([]RouterCfg, 0),
22 Clients: []ClientCfg{
23 {NodeCfg{
24 Id: "blah",
25 PubKey: NyPublicKey{},
26 Prefixes: []PrefixHealthWrapper{
27 {
28 &StaticPrefixHealth{
29 Prefix: netip.MustParsePrefix("10.0.0.1/32"),
30 Metric: 0,
31 },
32 },
33 },
34 }},
35 },
36 Graph: []string{
37 "blah, blah",
38 "a = blah",
39 "b = a",
40 "a, b",
41 },
42 Timestamp: 0,
43 }
44 txt, err := yaml.Marshal(cfg)
45 assert.NoError(t, err)
46 bundle, err := BundleConfig(string(txt), root)
47 assert.NoError(t, err)
48
49 finalCfg, err := UnbundleConfig(bundle, root.Pubkey())
50 assert.NoError(t, err)
51 finalCfg.Timestamp = 0 // cannot enforce timestamp to be the same
52 assert.EqualValues(t, cfg, *finalCfg)
53}
54
55func TestBundleTamper(t *testing.T) {
56 root := GenerateKey()

Callers

nothing calls this directly

Calls 4

GenerateKeyFunction · 0.85
BundleConfigFunction · 0.85
UnbundleConfigFunction · 0.85
PubkeyMethod · 0.80

Tested by

no test coverage detected