From 78ce39692e0721e0bfee2e6cd262eebf47f45fac Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 24 Dec 2016 16:57:59 -0600 Subject: [PATCH] lnwire: remove channel graph announcement validation tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit removes the previous test cases which excised the proper validation of graph announcements on the network. As full generation of the authenticated messages has not yet been implemented, these tests aren’t currently applicable. In a future commit, these tests will be replicated on the new discovery package which will handle producing the channel proofs and also fully validating them. --- lnwire/channel_announcement_test.go | 42 ----------------------------- lnwire/node_announcement_test.go | 26 ------------------ 2 files changed, 68 deletions(-) diff --git a/lnwire/channel_announcement_test.go b/lnwire/channel_announcement_test.go index 48990436..e85b2e72 100644 --- a/lnwire/channel_announcement_test.go +++ b/lnwire/channel_announcement_test.go @@ -89,45 +89,3 @@ func TestChannelAnnoucementValidation(t *testing.T) { t.Fatal(err) } } - -func TestChannelAnnoucementBadValidation(t *testing.T) { - getKeys := func(s string) (*btcec.PrivateKey, *btcec.PublicKey) { - return btcec.PrivKeyFromBytes(btcec.S256(), []byte(s)) - } - - firstNodePrivKey, firstNodePubKey := getKeys("node-id-1") - secondNodePrivKey, secondNodePubKey := getKeys("node-id-2") - firstBitcoinPrivKey, _ := getKeys("bitcoin-key-1") - secondBitcoinPrivKey, _ := getKeys("bitcoin-key-2") - - var hash []byte - - hash = wire.DoubleSha256(firstNodePubKey.SerializeCompressed()) - firstBitcoinSig, _ := firstBitcoinPrivKey.Sign(hash) - - hash = wire.DoubleSha256(secondNodePubKey.SerializeCompressed()) - secondBitcoinSig, _ := secondBitcoinPrivKey.Sign(hash) - - ca := &ChannelAnnouncement{ - ChannelID: someChannelID, - FirstBitcoinSig: firstBitcoinSig, - SecondBitcoinSig: secondBitcoinSig, - FirstNodeID: pubKey, // wrong pubkey - SecondNodeID: pubKey, // wrong pubkey - FirstBitcoinKey: pubKey, // wrong pubkey - SecondBitcoinKey: pubKey, // wrong pubkey - } - - dataToSign, _ := ca.DataToSign() - hash = wire.DoubleSha256(dataToSign) - - firstNodeSign, _ := firstNodePrivKey.Sign(hash) - ca.FirstNodeSig = firstNodeSign - - secondNodeSign, _ := secondNodePrivKey.Sign(hash) - ca.SecondNodeSig = secondNodeSign - - if err := ca.Validate(); err == nil { - t.Fatal("error should be raised") - } -} diff --git a/lnwire/node_announcement_test.go b/lnwire/node_announcement_test.go index ad7c5e7b..84eb1d99 100644 --- a/lnwire/node_announcement_test.go +++ b/lnwire/node_announcement_test.go @@ -68,32 +68,6 @@ func TestNodeAnnoucementValidation(t *testing.T) { } } -func TestNodeAnnoucementBadValidation(t *testing.T) { - getKeys := func(s string) (*btcec.PrivateKey, *btcec.PublicKey) { - return btcec.PrivKeyFromBytes(btcec.S256(), []byte(s)) - } - - na := &NodeAnnouncement{ - Timestamp: maxUint32, - Address: someAddress, - NodeID: pubKey, // wrong pubkey - RGBColor: someRGB, - pad: maxUint16, - Alias: someAlias, - } - - nodePrivKey, _ := getKeys("node-id-1") - dataToSign, _ := na.DataToSign() - hash := wire.DoubleSha256(dataToSign) - - signature, _ := nodePrivKey.Sign(hash) - na.Signature = signature - - if err := na.Validate(); err == nil { - t.Fatal("error wasn't raised") - } -} - func TestNodeAnnoucementPayloadLength(t *testing.T) { na := &NodeAnnouncement{ Signature: someSig,