From e8d2e407ffe170e4e0ebcd06bf27b50d3200f7ee Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Sat, 12 Apr 2025 09:22:43 -0400 Subject: [PATCH] chore: make format golines Signed-off-by: Chris Gianelloni --- internal/handshake/block_test.go | 90 ++++++++++++++++++++++------- internal/handshake/covenant.go | 8 ++- internal/handshake/covenant_test.go | 86 ++++++++++++++++++++------- internal/handshake/domain_test.go | 20 +++++-- 4 files changed, 154 insertions(+), 50 deletions(-) diff --git a/internal/handshake/block_test.go b/internal/handshake/block_test.go index 10a9b07..13fe009 100644 --- a/internal/handshake/block_test.go +++ b/internal/handshake/block_test.go @@ -25,15 +25,33 @@ func TestDecodeHandshakeBlock(t *testing.T) { testBlockHex := "c29fc32ba934ec67000000000000000000000008fb98a534f78c6594b9c5581d6e7ca688efebca93e3567d980b5cc7b8bb7632532df5d5adc0af9f2a830fcb72b2595cd7c4e34e6371465f17c907ca66957417a200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045779eb2591efda24b4e502cb186d6b7b3d786bb8b247180205b8e8edc70ec6c7daf23875654e512d4235898dfda96202d6a11f0314945c9835f60b8d14a64cc000000007093091900000000000000000000000000000000000000000000000000000000000000000200000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3b2cf8140134369b3b00000000001498c8297a67eb81ec36253828b5621a601ba2328a0000a62204000306566961425443087c524fd539e1eab808000000000000000000000000021b6c08ea3b56b781a821c5e5f01e93db09409bacb2c8fdbbc50659ba135ec66d00000000ffffffff74bcb7fae5c29b149c278e0b78afd22dcdfea1339ce28af0ff68a46a716d03fa05000000ffffffff02000000000000000000145ad99a3052017938562ede6e228b68ca50c14663080320c89c49ce327748244702f481f35097199cca2f7c2549a33ecacbdf973690e53404bf1e01002000000000000000020db257ed6d1c3b47b6e2299fbfcbef58996dcd6a30e9d86837107fe90d0000000014fb7148b38057231e023ce04e52a0d1d067a9100c0000000000000241cd37781b3ec75e9960e191825a5540aba2555a64c8efc58002f3b1163240f01b6696f298b1823c206223427738c81c79e6de38ac47138a005422b9a816354dab012102042f296a2e27a712cf445e05c5085e3e6eb7a0d1cdb2989f9259c1307e3de30c02418920c4adbced17aaa59ab3848789870ef0ef00d83eb608f622242d6f4347040f3de5ff8198c3716cdb66915f83936fdcc6a5d31aa00e2b8f2ac2bd290229f58d012103b5c60aea8ec43bb6a8574caf5817be3ac376ca46ca0db22d330cbd5909a1d8f1" expectedBlock := handshake.Block{ Header: handshake.BlockHeader{ - Nonce: 734240706, - Time: 1743533225, - PrevBlock: [32]byte(decodeHex("0000000000000008fb98a534f78c6594b9c5581d6e7ca688efebca93e3567d98")), - NameRoot: [32]byte(decodeHex("0b5cc7b8bb7632532df5d5adc0af9f2a830fcb72b2595cd7c4e34e6371465f17")), - ExtraNonce: [24]byte(decodeHex("c907ca66957417a200000000000000000000000000000000")), - WitnessRoot: [32]byte(decodeHex("45779eb2591efda24b4e502cb186d6b7b3d786bb8b247180205b8e8edc70ec6c")), - MerkleRoot: [32]byte(decodeHex("7daf23875654e512d4235898dfda96202d6a11f0314945c9835f60b8d14a64cc")), - Version: 0, - Bits: 420057968, + Nonce: 734240706, + Time: 1743533225, + PrevBlock: [32]byte( + decodeHex( + "0000000000000008fb98a534f78c6594b9c5581d6e7ca688efebca93e3567d98", + ), + ), + NameRoot: [32]byte( + decodeHex( + "0b5cc7b8bb7632532df5d5adc0af9f2a830fcb72b2595cd7c4e34e6371465f17", + ), + ), + ExtraNonce: [24]byte( + decodeHex("c907ca66957417a200000000000000000000000000000000"), + ), + WitnessRoot: [32]byte( + decodeHex( + "45779eb2591efda24b4e502cb186d6b7b3d786bb8b247180205b8e8edc70ec6c", + ), + ), + MerkleRoot: [32]byte( + decodeHex( + "7daf23875654e512d4235898dfda96202d6a11f0314945c9835f60b8d14a64cc", + ), + ), + Version: 0, + Bits: 420057968, }, Transactions: []handshake.Transaction{ { @@ -57,7 +75,9 @@ func TestDecodeHandshakeBlock(t *testing.T) { Value: 1000027700, Address: handshake.Address{ Version: 0, - Hash: decodeHex("98c8297a67eb81ec36253828b5621a601ba2328a"), + Hash: decodeHex( + "98c8297a67eb81ec36253828b5621a601ba2328a", + ), }, }, }, @@ -67,24 +87,40 @@ func TestDecodeHandshakeBlock(t *testing.T) { Inputs: []handshake.TransactionInput{ { PrevOutpoint: handshake.Outpoint{ - Hash: [32]byte(decodeHex("1b6c08ea3b56b781a821c5e5f01e93db09409bacb2c8fdbbc50659ba135ec66d")), + Hash: [32]byte( + decodeHex( + "1b6c08ea3b56b781a821c5e5f01e93db09409bacb2c8fdbbc50659ba135ec66d", + ), + ), Index: 0, }, Sequence: 0xffffffff, Witness: [][]byte{ - decodeHex("cd37781b3ec75e9960e191825a5540aba2555a64c8efc58002f3b1163240f01b6696f298b1823c206223427738c81c79e6de38ac47138a005422b9a816354dab01"), - decodeHex("02042f296a2e27a712cf445e05c5085e3e6eb7a0d1cdb2989f9259c1307e3de30c"), + decodeHex( + "cd37781b3ec75e9960e191825a5540aba2555a64c8efc58002f3b1163240f01b6696f298b1823c206223427738c81c79e6de38ac47138a005422b9a816354dab01", + ), + decodeHex( + "02042f296a2e27a712cf445e05c5085e3e6eb7a0d1cdb2989f9259c1307e3de30c", + ), }, }, { PrevOutpoint: handshake.Outpoint{ - Hash: [32]byte(decodeHex("74bcb7fae5c29b149c278e0b78afd22dcdfea1339ce28af0ff68a46a716d03fa")), + Hash: [32]byte( + decodeHex( + "74bcb7fae5c29b149c278e0b78afd22dcdfea1339ce28af0ff68a46a716d03fa", + ), + ), Index: 5, }, Sequence: 0xffffffff, Witness: [][]byte{ - decodeHex("8920c4adbced17aaa59ab3848789870ef0ef00d83eb608f622242d6f4347040f3de5ff8198c3716cdb66915f83936fdcc6a5d31aa00e2b8f2ac2bd290229f58d01"), - decodeHex("03b5c60aea8ec43bb6a8574caf5817be3ac376ca46ca0db22d330cbd5909a1d8f1"), + decodeHex( + "8920c4adbced17aaa59ab3848789870ef0ef00d83eb608f622242d6f4347040f3de5ff8198c3716cdb66915f83936fdcc6a5d31aa00e2b8f2ac2bd290229f58d01", + ), + decodeHex( + "03b5c60aea8ec43bb6a8574caf5817be3ac376ca46ca0db22d330cbd5909a1d8f1", + ), }, }, }, @@ -93,14 +129,20 @@ func TestDecodeHandshakeBlock(t *testing.T) { Value: 0, Address: handshake.Address{ Version: 0, - Hash: decodeHex("5ad99a3052017938562ede6e228b68ca50c14663"), + Hash: decodeHex( + "5ad99a3052017938562ede6e228b68ca50c14663", + ), }, Covenant: handshake.GenericCovenant{ Type: 8, Items: [][]byte{ - decodeHex("c89c49ce327748244702f481f35097199cca2f7c2549a33ecacbdf973690e534"), + decodeHex( + "c89c49ce327748244702f481f35097199cca2f7c2549a33ecacbdf973690e534", + ), decodeHex("bf1e0100"), - decodeHex("00000000000000020db257ed6d1c3b47b6e2299fbfcbef58996dcd6a30e9d868"), + decodeHex( + "00000000000000020db257ed6d1c3b47b6e2299fbfcbef58996dcd6a30e9d868", + ), }, }, }, @@ -108,7 +150,9 @@ func TestDecodeHandshakeBlock(t *testing.T) { Value: 59751993399, Address: handshake.Address{ Version: 0, - Hash: decodeHex("fb7148b38057231e023ce04e52a0d1d067a9100c"), + Hash: decodeHex( + "fb7148b38057231e023ce04e52a0d1d067a9100c", + ), }, }, }, @@ -133,7 +177,11 @@ func TestDecodeHandshakeBlock(t *testing.T) { ) } if len(block.Transactions) != len(expectedBlock.Transactions) { - t.Fatalf("did not get expected TX count: got %d, wanted %d", len(block.Transactions), len(expectedBlock.Transactions)) + t.Fatalf( + "did not get expected TX count: got %d, wanted %d", + len(block.Transactions), + len(expectedBlock.Transactions), + ) } for idx, testTx := range block.Transactions { expectedTx := expectedBlock.Transactions[idx] diff --git a/internal/handshake/covenant.go b/internal/handshake/covenant.go index bbd4d59..b4a79e2 100644 --- a/internal/handshake/covenant.go +++ b/internal/handshake/covenant.go @@ -89,7 +89,9 @@ type RegisterCovenant struct { func (RegisterCovenant) isCovenant() {} -func NewRegisterCovenantFromGeneric(gc *GenericCovenant) (*RegisterCovenant, error) { +func NewRegisterCovenantFromGeneric( + gc *GenericCovenant, +) (*RegisterCovenant, error) { if gc.Type != CovenantTypeRegister { return nil, errors.New("wrong covenant type") } @@ -123,7 +125,9 @@ type UpdateCovenant struct { func (UpdateCovenant) isCovenant() {} -func NewUpdateCovenantFromGeneric(gc *GenericCovenant) (*UpdateCovenant, error) { +func NewUpdateCovenantFromGeneric( + gc *GenericCovenant, +) (*UpdateCovenant, error) { if gc.Type != CovenantTypeUpdate { return nil, errors.New("wrong covenant type") } diff --git a/internal/handshake/covenant_test.go b/internal/handshake/covenant_test.go index 29d6f3d..8218b3f 100644 --- a/internal/handshake/covenant_test.go +++ b/internal/handshake/covenant_test.go @@ -19,15 +19,23 @@ func TestCovenantRegisterFromGeneric(t *testing.T) { testGenericCovenant := &handshake.GenericCovenant{ Type: handshake.CovenantTypeRegister, Items: [][]byte{ - decodeHex("62a90ce374b1499d0b67b1e4e6164b18acacbd16be905a6ffee593d48d4e0a82"), + decodeHex( + "62a90ce374b1499d0b67b1e4e6164b18acacbd16be905a6ffee593d48d4e0a82", + ), decodeHex("8d1e0400"), - decodeHex("0002036e73310a69727677696c6c69616d002ce706b701c00202036e7332c00636d688f601c01a00d5580d0114402ed0125506f35ba249265f39b988d7028a28c300d5580d02200c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de00d5580d043071cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9"), - decodeHex("0000000000000000153c62dbcabb762c254fb4104ab7cdd779926b79b34601fc"), + decodeHex( + "0002036e73310a69727677696c6c69616d002ce706b701c00202036e7332c00636d688f601c01a00d5580d0114402ed0125506f35ba249265f39b988d7028a28c300d5580d02200c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de00d5580d043071cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9", + ), + decodeHex( + "0000000000000000153c62dbcabb762c254fb4104ab7cdd779926b79b34601fc", + ), }, } expectedCovenant := &handshake.RegisterCovenant{ - NameHash: decodeHex("62a90ce374b1499d0b67b1e4e6164b18acacbd16be905a6ffee593d48d4e0a82"), - Height: 269965, + NameHash: decodeHex( + "62a90ce374b1499d0b67b1e4e6164b18acacbd16be905a6ffee593d48d4e0a82", + ), + Height: 269965, ResourceData: handshake.DomainResourceData{ Version: 0, Records: []handshake.DomainRecord{ @@ -49,27 +57,40 @@ func TestCovenantRegisterFromGeneric(t *testing.T) { KeyTag: 54616, Algorithm: 13, DigestType: 1, - Digest: decodeHex("402ed0125506f35ba249265f39b988d7028a28c3"), + Digest: decodeHex( + "402ed0125506f35ba249265f39b988d7028a28c3", + ), }, &handshake.DsDomainRecord{ KeyTag: 54616, Algorithm: 13, DigestType: 2, - Digest: decodeHex("0c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de"), + Digest: decodeHex( + "0c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de", + ), }, &handshake.DsDomainRecord{ KeyTag: 54616, Algorithm: 13, DigestType: 4, - Digest: decodeHex("71cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9"), + Digest: decodeHex( + "71cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9", + ), }, }, }, - BlockHash: decodeHex("0000000000000000153c62dbcabb762c254fb4104ab7cdd779926b79b34601fc"), + BlockHash: decodeHex( + "0000000000000000153c62dbcabb762c254fb4104ab7cdd779926b79b34601fc", + ), } - tmpCovenant, err := handshake.NewRegisterCovenantFromGeneric(testGenericCovenant) + tmpCovenant, err := handshake.NewRegisterCovenantFromGeneric( + testGenericCovenant, + ) if err != nil { - t.Fatalf("unexpected error creating RegisterCovenant from GenericCovenant: %s", err) + t.Fatalf( + "unexpected error creating RegisterCovenant from GenericCovenant: %s", + err, + ) } if !reflect.DeepEqual(tmpCovenant, expectedCovenant) { t.Fatalf( @@ -85,15 +106,23 @@ func TestCovenantUpdateFromGeneric(t *testing.T) { testGenericCovenant := &handshake.GenericCovenant{ Type: handshake.CovenantTypeUpdate, Items: [][]byte{ - decodeHex("62a90ce374b1499d0b67b1e4e6164b18acacbd16be905a6ffee593d48d4e0a82"), + decodeHex( + "62a90ce374b1499d0b67b1e4e6164b18acacbd16be905a6ffee593d48d4e0a82", + ), decodeHex("8d1e0400"), - decodeHex("0002036e73310a69727677696c6c69616d002ce706b701c00202036e7332c00636d688f601c01a00d5580d0114402ed0125506f35ba249265f39b988d7028a28c300d5580d02200c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de00d5580d043071cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9"), - decodeHex("0000000000000000153c62dbcabb762c254fb4104ab7cdd779926b79b34601fc"), + decodeHex( + "0002036e73310a69727677696c6c69616d002ce706b701c00202036e7332c00636d688f601c01a00d5580d0114402ed0125506f35ba249265f39b988d7028a28c300d5580d02200c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de00d5580d043071cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9", + ), + decodeHex( + "0000000000000000153c62dbcabb762c254fb4104ab7cdd779926b79b34601fc", + ), }, } expectedCovenant := &handshake.UpdateCovenant{ - NameHash: decodeHex("62a90ce374b1499d0b67b1e4e6164b18acacbd16be905a6ffee593d48d4e0a82"), - Height: 269965, + NameHash: decodeHex( + "62a90ce374b1499d0b67b1e4e6164b18acacbd16be905a6ffee593d48d4e0a82", + ), + Height: 269965, ResourceData: handshake.DomainResourceData{ Version: 0, Records: []handshake.DomainRecord{ @@ -115,27 +144,40 @@ func TestCovenantUpdateFromGeneric(t *testing.T) { KeyTag: 54616, Algorithm: 13, DigestType: 1, - Digest: decodeHex("402ed0125506f35ba249265f39b988d7028a28c3"), + Digest: decodeHex( + "402ed0125506f35ba249265f39b988d7028a28c3", + ), }, &handshake.DsDomainRecord{ KeyTag: 54616, Algorithm: 13, DigestType: 2, - Digest: decodeHex("0c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de"), + Digest: decodeHex( + "0c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de", + ), }, &handshake.DsDomainRecord{ KeyTag: 54616, Algorithm: 13, DigestType: 4, - Digest: decodeHex("71cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9"), + Digest: decodeHex( + "71cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9", + ), }, }, }, - BlockHash: decodeHex("0000000000000000153c62dbcabb762c254fb4104ab7cdd779926b79b34601fc"), + BlockHash: decodeHex( + "0000000000000000153c62dbcabb762c254fb4104ab7cdd779926b79b34601fc", + ), } - tmpCovenant, err := handshake.NewUpdateCovenantFromGeneric(testGenericCovenant) + tmpCovenant, err := handshake.NewUpdateCovenantFromGeneric( + testGenericCovenant, + ) if err != nil { - t.Fatalf("unexpected error creating UpdateCovenant from GenericCovenant: %s", err) + t.Fatalf( + "unexpected error creating UpdateCovenant from GenericCovenant: %s", + err, + ) } if !reflect.DeepEqual(tmpCovenant, expectedCovenant) { t.Fatalf( diff --git a/internal/handshake/domain_test.go b/internal/handshake/domain_test.go index f735cba..cf8c887 100644 --- a/internal/handshake/domain_test.go +++ b/internal/handshake/domain_test.go @@ -16,7 +16,9 @@ import ( func TestDomainResourceData(t *testing.T) { // This data comes from mainnet TX 63ba84b6362724aa8fd484d3616c8d1bdea68240c8e0cd6a104fcf85a35d52fb - testResourceDataBytes := decodeHex("0002036e73310a69727677696c6c69616d002ce706b701c00202036e7332c00636d688f601c01a00d5580d0114402ed0125506f35ba249265f39b988d7028a28c300d5580d02200c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de00d5580d043071cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9") + testResourceDataBytes := decodeHex( + "0002036e73310a69727677696c6c69616d002ce706b701c00202036e7332c00636d688f601c01a00d5580d0114402ed0125506f35ba249265f39b988d7028a28c300d5580d02200c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de00d5580d043071cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9", + ) expectedResourceData := &handshake.DomainResourceData{ Version: 0, Records: []handshake.DomainRecord{ @@ -38,23 +40,31 @@ func TestDomainResourceData(t *testing.T) { KeyTag: 54616, Algorithm: 13, DigestType: 1, - Digest: decodeHex("402ed0125506f35ba249265f39b988d7028a28c3"), + Digest: decodeHex( + "402ed0125506f35ba249265f39b988d7028a28c3", + ), }, &handshake.DsDomainRecord{ KeyTag: 54616, Algorithm: 13, DigestType: 2, - Digest: decodeHex("0c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de"), + Digest: decodeHex( + "0c6c45064c26b529b4ac074dff5de60a99d6025d5b0d7f32c2b8c7d40ec8b3de", + ), }, &handshake.DsDomainRecord{ KeyTag: 54616, Algorithm: 13, DigestType: 4, - Digest: decodeHex("71cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9"), + Digest: decodeHex( + "71cb0417852b08b965413f3b871b033996159d121a585e35111a335d4cfb79b67e49a99c3829f6a1f42e100f7f33d7d9", + ), }, }, } - tmpResourceData, err := handshake.NewDomainResourceDataFromBytes(testResourceDataBytes) + tmpResourceData, err := handshake.NewDomainResourceDataFromBytes( + testResourceDataBytes, + ) if err != nil { t.Fatalf("unexpected error decoding resource data: %s", err) }