breacharbiter_test: updated test vectors for new retInfo struct
This commit is contained in:
parent
5b6ab9a078
commit
4c19320ea0
@ -78,116 +78,135 @@ var (
|
||||
},
|
||||
}
|
||||
|
||||
breachSignDescs = []lnwallet.SignDescriptor{
|
||||
{
|
||||
SingleTweak: []byte{
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
},
|
||||
WitnessScript: []byte{
|
||||
0x00, 0x14, 0xee, 0x91, 0x41, 0x7e, 0x85, 0x6c, 0xde,
|
||||
0x10, 0xa2, 0x91, 0x1e, 0xdc, 0xbd, 0xbd, 0x69, 0xe2,
|
||||
0xef, 0xb5, 0x71, 0x48,
|
||||
},
|
||||
Output: &wire.TxOut{
|
||||
Value: 5000000000,
|
||||
PkScript: []byte{
|
||||
0x41, // OP_DATA_65
|
||||
0x04, 0xd6, 0x4b, 0xdf, 0xd0, 0x9e, 0xb1, 0xc5,
|
||||
0xfe, 0x29, 0x5a, 0xbd, 0xeb, 0x1d, 0xca, 0x42,
|
||||
0x81, 0xbe, 0x98, 0x8e, 0x2d, 0xa0, 0xb6, 0xc1,
|
||||
0xc6, 0xa5, 0x9d, 0xc2, 0x26, 0xc2, 0x86, 0x24,
|
||||
0xe1, 0x81, 0x75, 0xe8, 0x51, 0xc9, 0x6b, 0x97,
|
||||
0x3d, 0x81, 0xb0, 0x1c, 0xc3, 0x1f, 0x04, 0x78,
|
||||
0x34, 0xbc, 0x06, 0xd6, 0xd6, 0xed, 0xf6, 0x20,
|
||||
0xd1, 0x84, 0x24, 0x1a, 0x6a, 0xed, 0x8b, 0x63,
|
||||
0xa6, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
},
|
||||
},
|
||||
HashType: txscript.SigHashAll,
|
||||
},
|
||||
{
|
||||
SingleTweak: []byte{
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
},
|
||||
WitnessScript: []byte{
|
||||
0x00, 0x14, 0xee, 0x91, 0x41, 0x7e, 0x85, 0x6c, 0xde,
|
||||
0x10, 0xa2, 0x91, 0x1e, 0xdc, 0xbd, 0xbd, 0x69, 0xe2,
|
||||
0xef, 0xb5, 0x71, 0x48,
|
||||
},
|
||||
Output: &wire.TxOut{
|
||||
Value: 5000000000,
|
||||
PkScript: []byte{
|
||||
0x41, // OP_DATA_65
|
||||
0x04, 0xd6, 0x4b, 0xdf, 0xd0, 0x9e, 0xb1, 0xc5,
|
||||
0xfe, 0x29, 0x5a, 0xbd, 0xeb, 0x1d, 0xca, 0x42,
|
||||
0x81, 0xbe, 0x98, 0x8e, 0x2d, 0xa0, 0xb6, 0xc1,
|
||||
0xc6, 0xa5, 0x9d, 0xc2, 0x26, 0xc2, 0x86, 0x24,
|
||||
0xe1, 0x81, 0x75, 0xe8, 0x51, 0xc9, 0x6b, 0x97,
|
||||
0x3d, 0x81, 0xb0, 0x1c, 0xc3, 0x1f, 0x04, 0x78,
|
||||
0x34, 0xbc, 0x06, 0xd6, 0xd6, 0xed, 0xf6, 0x20,
|
||||
0xd1, 0x84, 0x24, 0x1a, 0x6a, 0xed, 0x8b, 0x63,
|
||||
0xa6, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
},
|
||||
},
|
||||
HashType: txscript.SigHashAll,
|
||||
},
|
||||
{
|
||||
SingleTweak: []byte{
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
},
|
||||
WitnessScript: []byte{
|
||||
0x00, 0x14, 0xee, 0x91, 0x41, 0x7e, 0x85, 0x6c, 0xde,
|
||||
0x10, 0xa2, 0x91, 0x1e, 0xdc, 0xbd, 0xbd, 0x69, 0xe2,
|
||||
0xef, 0xb5, 0x71, 0x48,
|
||||
},
|
||||
Output: &wire.TxOut{
|
||||
Value: 5000000000,
|
||||
PkScript: []byte{
|
||||
0x41, // OP_DATA_65
|
||||
0x04, 0xd6, 0x4b, 0xdf, 0xd0, 0x9e, 0xb1, 0xc5,
|
||||
0xfe, 0x29, 0x5a, 0xbd, 0xeb, 0x1d, 0xca, 0x42,
|
||||
0x81, 0xbe, 0x98, 0x8e, 0x2d, 0xa0, 0xb6, 0xc1,
|
||||
0xc6, 0xa5, 0x9d, 0xc2, 0x26, 0xc2, 0x86, 0x24,
|
||||
0xe1, 0x81, 0x75, 0xe8, 0x51, 0xc9, 0x6b, 0x97,
|
||||
0x3d, 0x81, 0xb0, 0x1c, 0xc3, 0x1f, 0x04, 0x78,
|
||||
0x34, 0xbc, 0x06, 0xd6, 0xd6, 0xed, 0xf6, 0x20,
|
||||
0xd1, 0x84, 0x24, 0x1a, 0x6a, 0xed, 0x8b, 0x63,
|
||||
0xa6, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
},
|
||||
},
|
||||
HashType: txscript.SigHashAll,
|
||||
},
|
||||
}
|
||||
|
||||
breachedOutputs = []breachedOutput{
|
||||
{
|
||||
amt: btcutil.Amount(1e7),
|
||||
outpoint: breachOutPoints[0],
|
||||
witnessType: lnwallet.CommitmentNoDelay,
|
||||
signDesc: lnwallet.SignDescriptor{
|
||||
SingleTweak: []byte{
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02,
|
||||
},
|
||||
WitnessScript: []byte{
|
||||
0x00, 0x14, 0xee, 0x91, 0x41, 0x7e,
|
||||
0x85, 0x6c, 0xde, 0x10, 0xa2, 0x91,
|
||||
0x1e, 0xdc, 0xbd, 0xbd, 0x69, 0xe2,
|
||||
0xef, 0xb5, 0x71, 0x48,
|
||||
},
|
||||
Output: &wire.TxOut{
|
||||
Value: 5000000000,
|
||||
PkScript: []byte{
|
||||
0x41, // OP_DATA_65
|
||||
0x04, 0xd6, 0x4b, 0xdf, 0xd0,
|
||||
0x9e, 0xb1, 0xc5, 0xfe, 0x29,
|
||||
0x5a, 0xbd, 0xeb, 0x1d, 0xca,
|
||||
0x42, 0x81, 0xbe, 0x98, 0x8e,
|
||||
0x2d, 0xa0, 0xb6, 0xc1, 0xc6,
|
||||
0xa5, 0x9d, 0xc2, 0x26, 0xc2,
|
||||
0x86, 0x24, 0xe1, 0x81, 0x75,
|
||||
0xe8, 0x51, 0xc9, 0x6b, 0x97,
|
||||
0x3d, 0x81, 0xb0, 0x1c, 0xc3,
|
||||
0x1f, 0x04, 0x78, 0x34, 0xbc,
|
||||
0x06, 0xd6, 0xd6, 0xed, 0xf6,
|
||||
0x20, 0xd1, 0x84, 0x24, 0x1a,
|
||||
0x6a, 0xed, 0x8b, 0x63,
|
||||
0xa6, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
},
|
||||
},
|
||||
HashType: txscript.SigHashAll,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
amt: btcutil.Amount(2e9),
|
||||
outpoint: breachOutPoints[1],
|
||||
witnessType: lnwallet.CommitmentRevoke,
|
||||
signDesc: lnwallet.SignDescriptor{
|
||||
SingleTweak: []byte{
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02,
|
||||
},
|
||||
WitnessScript: []byte{
|
||||
0x00, 0x14, 0xee, 0x91, 0x41, 0x7e,
|
||||
0x85, 0x6c, 0xde, 0x10, 0xa2, 0x91,
|
||||
0x1e, 0xdc, 0xbd, 0xbd, 0x69, 0xe2,
|
||||
0xef, 0xb5, 0x71, 0x48,
|
||||
},
|
||||
Output: &wire.TxOut{
|
||||
Value: 5000000000,
|
||||
PkScript: []byte{
|
||||
0x41, // OP_DATA_65
|
||||
0x04, 0xd6, 0x4b, 0xdf, 0xd0,
|
||||
0x9e, 0xb1, 0xc5, 0xfe, 0x29,
|
||||
0x5a, 0xbd, 0xeb, 0x1d, 0xca,
|
||||
0x42, 0x81, 0xbe, 0x98, 0x8e,
|
||||
0x2d, 0xa0, 0xb6, 0xc1, 0xc6,
|
||||
0xa5, 0x9d, 0xc2, 0x26, 0xc2,
|
||||
0x86, 0x24, 0xe1, 0x81, 0x75,
|
||||
0xe8, 0x51, 0xc9, 0x6b, 0x97,
|
||||
0x3d, 0x81, 0xb0, 0x1c, 0xc3,
|
||||
0x1f, 0x04, 0x78, 0x34, 0xbc,
|
||||
0x06, 0xd6, 0xd6, 0xed, 0xf6,
|
||||
0x20, 0xd1, 0x84, 0x24, 0x1a,
|
||||
0x6a, 0xed, 0x8b, 0x63,
|
||||
0xa6, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
},
|
||||
},
|
||||
HashType: txscript.SigHashAll,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
amt: btcutil.Amount(3e4),
|
||||
outpoint: breachOutPoints[2],
|
||||
witnessType: lnwallet.CommitmentDelayOutput,
|
||||
signDesc: lnwallet.SignDescriptor{
|
||||
SingleTweak: []byte{
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02,
|
||||
},
|
||||
WitnessScript: []byte{
|
||||
0x00, 0x14, 0xee, 0x91, 0x41, 0x7e,
|
||||
0x85, 0x6c, 0xde, 0x10, 0xa2, 0x91,
|
||||
0x1e, 0xdc, 0xbd, 0xbd, 0x69, 0xe2,
|
||||
0xef, 0xb5, 0x71, 0x48,
|
||||
},
|
||||
Output: &wire.TxOut{
|
||||
Value: 5000000000,
|
||||
PkScript: []byte{
|
||||
0x41, // OP_DATA_65
|
||||
0x04, 0xd6, 0x4b, 0xdf, 0xd0,
|
||||
0x9e, 0xb1, 0xc5, 0xfe, 0x29,
|
||||
0x5a, 0xbd, 0xeb, 0x1d, 0xca,
|
||||
0x42, 0x81, 0xbe, 0x98, 0x8e,
|
||||
0x2d, 0xa0, 0xb6, 0xc1, 0xc6,
|
||||
0xa5, 0x9d, 0xc2, 0x26, 0xc2,
|
||||
0x86, 0x24, 0xe1, 0x81, 0x75,
|
||||
0xe8, 0x51, 0xc9, 0x6b, 0x97,
|
||||
0x3d, 0x81, 0xb0, 0x1c, 0xc3,
|
||||
0x1f, 0x04, 0x78, 0x34, 0xbc,
|
||||
0x06, 0xd6, 0xd6, 0xed, 0xf6,
|
||||
0x20, 0xd1, 0x84, 0x24, 0x1a,
|
||||
0x6a, 0xed, 0x8b, 0x63,
|
||||
0xa6, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
},
|
||||
},
|
||||
HashType: txscript.SigHashAll,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -203,9 +222,8 @@ var (
|
||||
chanPoint: breachOutPoints[0],
|
||||
capacity: btcutil.Amount(1e7),
|
||||
settledBalance: btcutil.Amount(1e7),
|
||||
selfOutput: &breachedOutputs[0],
|
||||
revokedOutput: &breachedOutputs[1],
|
||||
htlcOutputs: []*breachedOutput{},
|
||||
// Set to breachedOutputs 0 and 1 in init()
|
||||
breachedOutputs: []breachedOutput{{}, {}},
|
||||
},
|
||||
{
|
||||
commitHash: [chainhash.HashSize]byte{
|
||||
@ -217,12 +235,8 @@ var (
|
||||
chanPoint: breachOutPoints[1],
|
||||
capacity: btcutil.Amount(1e7),
|
||||
settledBalance: btcutil.Amount(1e7),
|
||||
selfOutput: &breachedOutputs[0],
|
||||
revokedOutput: &breachedOutputs[1],
|
||||
htlcOutputs: []*breachedOutput{
|
||||
&breachedOutputs[1],
|
||||
&breachedOutputs[2],
|
||||
},
|
||||
// Set to breachedOutputs 1 and 2 in init()
|
||||
breachedOutputs: []breachedOutput{{}, {}},
|
||||
},
|
||||
}
|
||||
)
|
||||
@ -238,7 +252,11 @@ func init() {
|
||||
for i := range retributions {
|
||||
retInfo := &retributions[i]
|
||||
retInfo.remoteIdentity = breachedOutputs[i].signDesc.PubKey
|
||||
retInfo.breachedOutputs[0] = breachedOutputs[i]
|
||||
retInfo.breachedOutputs[1] = breachedOutputs[i+1]
|
||||
|
||||
retributionMap[retInfo.chanPoint] = *retInfo
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,14 +328,12 @@ func initBreachedOutputs() error {
|
||||
bo := &breachedOutputs[i]
|
||||
|
||||
// Parse the sign descriptor's pubkey.
|
||||
sd := &breachSignDescs[i]
|
||||
pubkey, err := btcec.ParsePubKey(breachKeys[i], btcec.S256())
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to parse pubkey: %v",
|
||||
breachKeys[i])
|
||||
}
|
||||
sd.PubKey = pubkey
|
||||
bo.signDesc = *sd
|
||||
bo.signDesc.PubKey = pubkey
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -325,7 +341,7 @@ func initBreachedOutputs() error {
|
||||
|
||||
// Test that breachedOutput Encode/Decode works.
|
||||
func TestBreachedOutputSerialization(t *testing.T) {
|
||||
for i := 0; i < len(breachedOutputs); i++ {
|
||||
for i := range breachedOutputs {
|
||||
bo := &breachedOutputs[i]
|
||||
|
||||
var buf bytes.Buffer
|
||||
@ -353,7 +369,7 @@ func TestBreachedOutputSerialization(t *testing.T) {
|
||||
|
||||
// Test that retribution Encode/Decode works.
|
||||
func TestRetributionSerialization(t *testing.T) {
|
||||
for i := 0; i < len(retributions); i++ {
|
||||
for i := range retributions {
|
||||
ret := &retributions[i]
|
||||
|
||||
var buf bytes.Buffer
|
||||
@ -381,21 +397,19 @@ func TestRetributionSerialization(t *testing.T) {
|
||||
|
||||
// copyRetInfo creates a complete copy of the given retributionInfo.
|
||||
func copyRetInfo(retInfo *retributionInfo) *retributionInfo {
|
||||
nHtlcs := len(retInfo.htlcOutputs)
|
||||
nOutputs := len(retInfo.breachedOutputs)
|
||||
|
||||
ret := &retributionInfo{
|
||||
commitHash: retInfo.commitHash,
|
||||
chanPoint: retInfo.chanPoint,
|
||||
remoteIdentity: retInfo.remoteIdentity,
|
||||
capacity: retInfo.capacity,
|
||||
settledBalance: retInfo.settledBalance,
|
||||
selfOutput: retInfo.selfOutput,
|
||||
revokedOutput: retInfo.revokedOutput,
|
||||
htlcOutputs: make([]*breachedOutput, nHtlcs),
|
||||
commitHash: retInfo.commitHash,
|
||||
chanPoint: retInfo.chanPoint,
|
||||
remoteIdentity: retInfo.remoteIdentity,
|
||||
capacity: retInfo.capacity,
|
||||
settledBalance: retInfo.settledBalance,
|
||||
breachedOutputs: make([]breachedOutput, nOutputs),
|
||||
}
|
||||
|
||||
for i, htlco := range retInfo.htlcOutputs {
|
||||
ret.htlcOutputs[i] = htlco
|
||||
for i := range retInfo.breachedOutputs {
|
||||
ret.breachedOutputs[i] = retInfo.breachedOutputs[i]
|
||||
}
|
||||
|
||||
return ret
|
||||
|
Loading…
Reference in New Issue
Block a user