github.com/decred/dcrlnd@v0.7.6/lnwire/short_channel_id_test.go (about) 1 package lnwire 2 3 import ( 4 "reflect" 5 "testing" 6 7 "github.com/davecgh/go-spew/spew" 8 ) 9 10 func TestShortChannelIDEncoding(t *testing.T) { 11 t.Parallel() 12 13 var testCases = []ShortChannelID{ 14 { 15 BlockHeight: (1 << 24) - 1, 16 TxIndex: (1 << 24) - 1, 17 TxPosition: (1 << 16) - 1, 18 }, 19 { 20 BlockHeight: 2304934, 21 TxIndex: 2345, 22 TxPosition: 5, 23 }, 24 { 25 BlockHeight: 9304934, 26 TxIndex: 2345, 27 TxPosition: 5233, 28 }, 29 } 30 31 for _, testCase := range testCases { 32 chanInt := testCase.ToUint64() 33 34 newChanID := NewShortChanIDFromInt(chanInt) 35 36 if !reflect.DeepEqual(testCase, newChanID) { 37 t.Fatalf("chan ID's don't match: expected %v got %v", 38 spew.Sdump(testCase), spew.Sdump(newChanID)) 39 } 40 } 41 }