Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/addr: add missing MustParseIA,AS,ISD functions #4564

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion acceptance/router_benchmark/cases/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ go_library(
"//pkg/addr:go_default_library",
"//pkg/log:go_default_library",
"//pkg/private/util:go_default_library",
"//pkg/private/xtest:go_default_library",
"//pkg/scrypto:go_default_library",
"//pkg/slayers:go_default_library",
"//pkg/slayers/path:go_default_library",
Expand Down
5 changes: 2 additions & 3 deletions acceptance/router_benchmark/cases/topo.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (

"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/log"
"github.com/scionproto/scion/pkg/private/xtest"
"github.com/scionproto/scion/pkg/scrypto"
)

Expand Down Expand Up @@ -103,9 +102,9 @@ func InternalIPPort(AS byte, routerIndex byte) (netip.Addr, layers.UDPPort) {
// All are in ISD-1, except AS 4.
func ISDAS(AS byte) addr.IA {
if AS == 4 {
return xtest.MustParseIA(fmt.Sprintf("2-ff00:0:%d", AS))
return addr.MustParseIA(fmt.Sprintf("2-ff00:0:%d", AS))
}
return xtest.MustParseIA(fmt.Sprintf("1-ff00:0:%d", AS))
return addr.MustParseIA(fmt.Sprintf("1-ff00:0:%d", AS))
}

func FakeMAC(AS byte) hash.Hash {
Expand Down
2 changes: 1 addition & 1 deletion control/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ go_test(
data = glob(["testdata/**"]),
deps = [
":go_default_library",
"//pkg/private/xtest:go_default_library",
"//pkg/addr:go_default_library",
"//private/app/command:go_default_library",
"//private/storage/trust/sqlite:go_default_library",
"//scion-pki/testcrypto:go_default_library",
Expand Down
1 change: 0 additions & 1 deletion control/beacon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ go_test(
":go_default_library",
"//control/beacon/mock_beacon:go_default_library",
"//pkg/addr:go_default_library",
"//pkg/private/xtest:go_default_library",
"//pkg/private/xtest/graph:go_default_library",
"//pkg/segment:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
Expand Down
15 changes: 7 additions & 8 deletions control/beacon/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ import (

"github.com/scionproto/scion/control/beacon"
"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/private/xtest"
seg "github.com/scionproto/scion/pkg/segment"
)

var (
ia110 = xtest.MustParseIA("1-ff00:0:110")
ia111 = xtest.MustParseIA("1-ff00:0:111")
ia112 = xtest.MustParseIA("1-ff00:0:112")
ia113 = xtest.MustParseIA("1-ff00:0:113")
ia210 = xtest.MustParseIA("2-ff00:0:210")
ia310 = xtest.MustParseIA("3-ff00:0:310")
ia311 = xtest.MustParseIA("3-ff00:0:311")
ia110 = addr.MustParseIA("1-ff00:0:110")
ia111 = addr.MustParseIA("1-ff00:0:111")
ia112 = addr.MustParseIA("1-ff00:0:112")
ia113 = addr.MustParseIA("1-ff00:0:113")
ia210 = addr.MustParseIA("2-ff00:0:210")
ia310 = addr.MustParseIA("3-ff00:0:310")
ia311 = addr.MustParseIA("3-ff00:0:311")

false_val = false
true_val = true
Expand Down
5 changes: 2 additions & 3 deletions control/beacon/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/scionproto/scion/control/beacon"
"github.com/scionproto/scion/control/beacon/mock_beacon"
"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/private/xtest"
"github.com/scionproto/scion/pkg/private/xtest/graph"
seg "github.com/scionproto/scion/pkg/segment"
)
Expand Down Expand Up @@ -165,7 +164,7 @@ func testCoreStoreSelection(t *testing.T,
// Ensure remote out if is set in last AS entry.
stub := graph.If_210_X_220_X

ia120 := xtest.MustParseIA("1-ff00:0:120")
ia120 := addr.MustParseIA("1-ff00:0:120")
beacons120 := []beacon.Beacon{
testBeacon(g, graph.If_120_A_110_X, graph.If_110_X_210_X, stub),
testBeacon(g, graph.If_120_B_220_X, graph.If_220_X_210_X, stub),
Expand All @@ -177,7 +176,7 @@ func testCoreStoreSelection(t *testing.T,
testBeacon(g, graph.If_120_A_110_X, graph.If_110_X_210_X, stub),
}

ia130 := xtest.MustParseIA("1-ff00:0:130")
ia130 := addr.MustParseIA("1-ff00:0:130")
beacons130 := []beacon.Beacon{
testBeacon(g, graph.If_130_A_110_X, graph.If_110_X_210_X, stub),
testBeacon(g, graph.If_130_B_120_A, graph.If_120_A_110_X, graph.If_110_X_210_X, stub),
Expand Down
1 change: 0 additions & 1 deletion control/beaconing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ go_test(
"//pkg/private/common:go_default_library",
"//pkg/private/serrors:go_default_library",
"//pkg/private/util:go_default_library",
"//pkg/private/xtest:go_default_library",
"//pkg/private/xtest/graph:go_default_library",
"//pkg/proto/crypto:go_default_library",
"//pkg/scrypto:go_default_library",
Expand Down
8 changes: 4 additions & 4 deletions control/beaconing/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/scionproto/scion/control/beaconing"
"github.com/scionproto/scion/control/beaconing/mock_beaconing"
"github.com/scionproto/scion/control/ifstate"
"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/private/serrors"
"github.com/scionproto/scion/pkg/private/xtest"
"github.com/scionproto/scion/pkg/private/xtest/graph"
seg "github.com/scionproto/scion/pkg/segment"
"github.com/scionproto/scion/pkg/snet"
Expand All @@ -37,7 +37,7 @@ import (
)

var (
localIA = xtest.MustParseIA("1-ff00:0:110")
localIA = addr.MustParseIA("1-ff00:0:110")
localIF = graph.If_110_X_120_A
)

Expand Down Expand Up @@ -158,7 +158,7 @@ func TestHandlerHandleBeacon(t *testing.T) {
}),
InIfId: localIF,
}
b.Segment.ASEntries[b.Segment.MaxIdx()].Local = xtest.MustParseIA("1-ff00:0:111")
b.Segment.ASEntries[b.Segment.MaxIdx()].Local = addr.MustParseIA("1-ff00:0:111")
return b

},
Expand Down Expand Up @@ -187,7 +187,7 @@ func TestHandlerHandleBeacon(t *testing.T) {
}),
InIfId: localIF,
}
b.Segment.ASEntries[b.Segment.MaxIdx()].Next = xtest.MustParseIA("1-ff00:0:111")
b.Segment.ASEntries[b.Segment.MaxIdx()].Next = addr.MustParseIA("1-ff00:0:111")
return b
},
Peer: func() *snet.UDPAddr {
Expand Down
4 changes: 2 additions & 2 deletions control/drkey/grpc/drkey_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import (
)

var (
ia111 = xtest.MustParseIA("1-ff00:0:111")
ia112 = xtest.MustParseIA("1-ff00:0:112")
ia111 = addr.MustParseIA("1-ff00:0:111")
ia112 = addr.MustParseIA("1-ff00:0:112")
tcpHost1 = netip.MustParseAddrPort("127.0.0.1:12345")
tcpHost2 = netip.MustParseAddrPort("127.0.0.2:12345")
)
Expand Down
3 changes: 2 additions & 1 deletion control/drkey/grpc/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
csdrkey "github.com/scionproto/scion/control/drkey"
dk_grpc "github.com/scionproto/scion/control/drkey/grpc"
"github.com/scionproto/scion/control/drkey/grpc/mock_grpc"
"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/drkey"
"github.com/scionproto/scion/pkg/private/xtest"
cppb "github.com/scionproto/scion/pkg/proto/control_plane"
Expand Down Expand Up @@ -136,7 +137,7 @@ func TestLevel1KeyFetching(t *testing.T) {
meta := drkey.Level1Meta{
ProtoId: drkey.Generic,
Validity: time.Now(),
SrcIA: xtest.MustParseIA("1-ff00:0:111"),
SrcIA: addr.MustParseIA("1-ff00:0:111"),
}
_, err = fetcher.Level1(context.Background(), meta)
tc.assertErr(t, err)
Expand Down
5 changes: 3 additions & 2 deletions control/drkey/grpc/protobuf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/scionproto/scion/control/drkey/grpc"
"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/drkey"
"github.com/scionproto/scion/pkg/private/util"
"github.com/scionproto/scion/pkg/private/xtest"
Expand All @@ -31,8 +32,8 @@ import (
)

var (
dstIA = xtest.MustParseIA("1-ff00:0:110")
srcIA = xtest.MustParseIA("1-ff00:0:111")
dstIA = addr.MustParseIA("1-ff00:0:110")
srcIA = addr.MustParseIA("1-ff00:0:111")
k = xtest.MustParseHexString("c584cad32613547c64823c756651b6f5") // just a key
strAddr = "127.0.0.1"
)
Expand Down
8 changes: 4 additions & 4 deletions control/drkey/prefetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (

cs_drkey "github.com/scionproto/scion/control/drkey"
"github.com/scionproto/scion/control/drkey/mock_drkey"
"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/drkey"
"github.com/scionproto/scion/pkg/private/xtest"
"github.com/scionproto/scion/private/periodic"
)

Expand All @@ -39,23 +39,23 @@ func TestPrefetcherRun(t *testing.T) {

prefetcher := cs_drkey.Prefetcher{
Engine: mock_engine,
LocalIA: xtest.MustParseIA("1-ff00:0:110"),
LocalIA: addr.MustParseIA("1-ff00:0:110"),
KeyDuration: time.Hour,
}

firstCached := mock_engine.EXPECT().GetLevel1PrefetchInfo().Times(1).Return(nil)

cachedKeys := []cs_drkey.Level1PrefetchInfo{
{
IA: xtest.MustParseIA("1-ff00:0:112"),
IA: addr.MustParseIA("1-ff00:0:112"),
Proto: drkey.SCMP,
},
}
secondCached := mock_engine.EXPECT().GetLevel1PrefetchInfo().After(
firstCached).Times(1).Return(cachedKeys)

cachedKeys = append(cachedKeys, cs_drkey.Level1PrefetchInfo{
IA: xtest.MustParseIA("1-ff00:0:111"),
IA: addr.MustParseIA("1-ff00:0:111"),
Proto: drkey.SCMP,
})
mock_engine.EXPECT().GetLevel1PrefetchInfo().After(
Expand Down
7 changes: 4 additions & 3 deletions control/drkey/service_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

cs_drkey "github.com/scionproto/scion/control/drkey"
"github.com/scionproto/scion/control/drkey/mock_drkey"
"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/drkey"
"github.com/scionproto/scion/pkg/private/serrors"
"github.com/scionproto/scion/pkg/private/util"
Expand All @@ -35,8 +36,8 @@ import (

var (
masterKey = xtest.MustParseHexString("305554050357005ae398259bcdae7468")
srcIA = xtest.MustParseIA("1-ff00:0:112")
dstIA = xtest.MustParseIA("1-ff00:0:111")
srcIA = addr.MustParseIA("1-ff00:0:112")
dstIA = addr.MustParseIA("1-ff00:0:111")
srcHost = "10.1.1.12"
)

Expand Down Expand Up @@ -253,7 +254,7 @@ func TestGetLevel1Key(t *testing.T) {
// Requesting local key should not update the cache
locallvl1Meta := drkey.Level1Meta{
SrcIA: dstIA,
DstIA: xtest.MustParseIA("1-ff00:0:111"),
DstIA: addr.MustParseIA("1-ff00:0:111"),
ProtoId: drkey.Generic,
Validity: util.SecsToTime(1).UTC(),
}
Expand Down
1 change: 1 addition & 0 deletions control/mgmtapi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ go_test(
"//control/mgmtapi/mock_mgmtapi:go_default_library",
"//control/trust:go_default_library",
"//control/trust/mock_trust:go_default_library",
"//pkg/addr:go_default_library",
"//pkg/private/serrors:go_default_library",
"//pkg/private/xtest:go_default_library",
"//pkg/scrypto/cppki:go_default_library",
Expand Down
19 changes: 10 additions & 9 deletions control/mgmtapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/scionproto/scion/control/mgmtapi/mock_mgmtapi"
cstrust "github.com/scionproto/scion/control/trust"
"github.com/scionproto/scion/control/trust/mock_trust"
"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/private/serrors"
"github.com/scionproto/scion/pkg/private/xtest"
"github.com/scionproto/scion/pkg/scrypto/cppki"
Expand Down Expand Up @@ -293,7 +294,7 @@ func TestAPI(t *testing.T) {
s.SetNowProvider(func() time.Time { return now })
g.EXPECT().Generate(gomock.Any()).AnyTimes().Return(
[]trust.Signer{{
IA: xtest.MustParseIA("1-ff00:0:110"),
IA: addr.MustParseIA("1-ff00:0:110"),
Algorithm: signed.ECDSAWithSHA512,
Subject: pkix.Name{
Country: []string{"CH"},
Expand Down Expand Up @@ -921,8 +922,8 @@ func createBeacons(t *testing.T) []beacon.Beacon {
},
ASEntries: []seg.ASEntry{
{
Local: xtest.MustParseIA("1-ff00:0:110"),
Next: xtest.MustParseIA("1-ff00:0:111"),
Local: addr.MustParseIA("1-ff00:0:110"),
Next: addr.MustParseIA("1-ff00:0:111"),
HopEntry: seg.HopEntry{
HopField: seg.HopField{
ConsIngress: 0,
Expand All @@ -932,8 +933,8 @@ func createBeacons(t *testing.T) []beacon.Beacon {
},
},
{
Local: xtest.MustParseIA("1-ff00:0:111"),
Next: xtest.MustParseIA("1-ff00:0:112"),
Local: addr.MustParseIA("1-ff00:0:111"),
Next: addr.MustParseIA("1-ff00:0:112"),
HopEntry: seg.HopEntry{
HopField: seg.HopField{
ConsIngress: 2,
Expand All @@ -957,8 +958,8 @@ func createBeacons(t *testing.T) []beacon.Beacon {
},
ASEntries: []seg.ASEntry{
{
Local: xtest.MustParseIA("2-ff00:0:220"),
Next: xtest.MustParseIA("3-ff00:0:330"),
Local: addr.MustParseIA("2-ff00:0:220"),
Next: addr.MustParseIA("3-ff00:0:330"),
HopEntry: seg.HopEntry{
HopField: seg.HopField{
ConsIngress: 0,
Expand All @@ -967,8 +968,8 @@ func createBeacons(t *testing.T) []beacon.Beacon {
},
},
{
Local: xtest.MustParseIA("3-ff00:0:330"),
Next: xtest.MustParseIA("4-ff00:0:440"),
Local: addr.MustParseIA("3-ff00:0:330"),
Next: addr.MustParseIA("4-ff00:0:440"),
HopEntry: seg.HopEntry{
HopField: seg.HopField{
ConsIngress: 6,
Expand Down
1 change: 0 additions & 1 deletion control/segreq/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ go_test(
embed = [":go_default_library"],
deps = [
"//pkg/addr:go_default_library",
"//pkg/private/xtest:go_default_library",
"//pkg/segment:go_default_library",
"//private/trust:go_default_library",
"//private/trust/mock_trust:go_default_library",
Expand Down
17 changes: 8 additions & 9 deletions control/segreq/forwarder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ import (
"github.com/stretchr/testify/require"

"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/private/xtest"
seg "github.com/scionproto/scion/pkg/segment"
"github.com/scionproto/scion/private/trust"
"github.com/scionproto/scion/private/trust/mock_trust"
)

var (
core110 = xtest.MustParseIA("1-ff00:0:110")
core120 = xtest.MustParseIA("1-ff00:0:120")
core130 = xtest.MustParseIA("1-ff00:0:130")
core210 = xtest.MustParseIA("2-ff00:0:210")
core110 = addr.MustParseIA("1-ff00:0:110")
core120 = addr.MustParseIA("1-ff00:0:120")
core130 = addr.MustParseIA("1-ff00:0:130")
core210 = addr.MustParseIA("2-ff00:0:210")

nonCore111 = xtest.MustParseIA("1-ff00:0:111")
nonCore112 = xtest.MustParseIA("1-ff00:0:112")
nonCore211 = xtest.MustParseIA("2-ff00:0:211")
nonCore212 = xtest.MustParseIA("2-ff00:0:212")
nonCore111 = addr.MustParseIA("1-ff00:0:111")
nonCore112 = addr.MustParseIA("1-ff00:0:112")
nonCore211 = addr.MustParseIA("2-ff00:0:211")
nonCore212 = addr.MustParseIA("2-ff00:0:212")

cores = map[addr.IA]struct{}{
core110: {},
Expand Down
Loading
Loading