Skip to content
Draft
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion testutil/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
return multiaddr.Join(maddr, port)
}

func RandomCID(t *testing.T) datamodel.Link {
func RandomCID(t *testing.T) cidlink.Link {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this would be breaking, but I really wish the method returned a cid.Cid, instead of whatever a cidlink.Link is..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. cidlink.Link is just a link that's implemented with a CID. It's weird because I don't know of any other kinds of links in IPLD? It seems like they have to be CIDs? But technically ipld.Link is a generic interface, and cidlink.Link implements that interface using CIDs, so you have to know you have one to pull the actual CID out.

Ideally, this would be called RandomLink() and RandomCID() would return a cidCid, but…well, someday, I hope.

Copy link
Member

@alanshaw alanshaw Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this would be breaking, but I really wish the method returned a cid.Cid, instead of whatever a cidlink.Link is..

I mean, at least you can get the cid.Cid out of this now without type asserting...

I feel like this might be my fault...sorry. I would get behind a RandomCID -> RandomLink rename and a new RandomCID method that actually returns a cid.Cid.

return cidlink.Link{Cid: cid.NewCidV1(cid.Raw, RandomMultihash(t))}
}

Expand Down Expand Up @@ -211,9 +211,9 @@

func RandomIndexClaimProviderResult(t *testing.T) model.ProviderResult {
indexMeta := metadata.IndexClaimMetadata{
Index: RandomCID(t).(cidlink.Link).Cid,

Check failure on line 214 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-check / All

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 214 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-check / All

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 214 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-test / ubuntu (go this)

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 214 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-test / macos (go this)

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface
Expiration: 0,
Claim: RandomCID(t).(cidlink.Link).Cid,

Check failure on line 216 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-check / All

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 216 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-check / All

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 216 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-test / ubuntu (go this)

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 216 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-test / macos (go this)

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface
}
metaBytes := Must(indexMeta.MarshalBinary())(t)

Expand All @@ -223,12 +223,12 @@
}

func RandomLocationCommitmentProviderResult(t *testing.T) model.ProviderResult {
shard := RandomCID(t).(cidlink.Link).Cid

Check failure on line 226 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-check / All

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 226 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-check / All

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 226 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-test / ubuntu (go this)

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 226 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-test / macos (go this)

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface
locationMeta := metadata.LocationCommitmentMetadata{
Shard: &shard,
Range: &metadata.Range{Offset: 128},
Expiration: 0,
Claim: RandomCID(t).(cidlink.Link).Cid,

Check failure on line 231 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-check / All

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface (compile)

Check failure on line 231 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-check / All

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 231 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-test / ubuntu (go this)

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface

Check failure on line 231 in testutil/gen.go

View workflow job for this annotation

GitHub Actions / go-test / macos (go this)

invalid operation: RandomCID(t) (value of struct type cidlink.Link) is not an interface
}
metaBytes := Must(locationMeta.MarshalBinary())(t)

Expand Down
Loading