mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-05 17:05:50 +02:00
record: add AMP record and encode/decode methods
This commit is contained in:
@@ -17,8 +17,11 @@ type recordEncDecTest struct {
|
||||
}
|
||||
|
||||
var (
|
||||
testTotal = lnwire.MilliSatoshi(45)
|
||||
testAddr = [32]byte{0x01, 0x02}
|
||||
testTotal = lnwire.MilliSatoshi(45)
|
||||
testAddr = [32]byte{0x01, 0x02}
|
||||
testShare = [32]byte{0x03, 0x04}
|
||||
testSetID = [32]byte{0x05, 0x06}
|
||||
testChildIndex = uint16(17)
|
||||
)
|
||||
|
||||
var recordEncDecTests = []recordEncDecTest{
|
||||
@@ -40,6 +43,29 @@ var recordEncDecTests = []recordEncDecTest{
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "amp",
|
||||
encRecord: func() tlv.RecordProducer {
|
||||
return record.NewAMP(
|
||||
testShare, testSetID, testChildIndex,
|
||||
)
|
||||
},
|
||||
decRecord: func() tlv.RecordProducer {
|
||||
return new(record.AMP)
|
||||
},
|
||||
assert: func(t *testing.T, r interface{}) {
|
||||
amp := r.(*record.AMP)
|
||||
if amp.RootShare() != testShare {
|
||||
t.Fatal("incorrect root share")
|
||||
}
|
||||
if amp.SetID() != testSetID {
|
||||
t.Fatal("incorrect set id")
|
||||
}
|
||||
if amp.ChildIndex() != testChildIndex {
|
||||
t.Fatal("incorrect child index")
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// TestRecordEncodeDecode is a generic test framework for custom TLV records. It
|
||||
|
Reference in New Issue
Block a user