|
37 | 37 | ) |
38 | 38 | ) |
39 | 39 |
|
| 40 | + |
| 41 | +func RandAssetForPacket(t testing.TB, assetType asset.Type, |
| 42 | + desc keychain.KeyDescriptor) *asset.Asset { |
| 43 | + |
| 44 | + randAsset := asset.RandAsset(t, assetType) |
| 45 | + randAsset.ScriptKey = asset.NewScriptKeyBip86(desc) |
| 46 | + |
| 47 | + // The raw key won't be serialized within the asset, so let's blank it |
| 48 | + // out here to get a fully, byte-by-byte comparable PSBT. |
| 49 | + randAsset.GroupKey.RawKey = keychain.KeyDescriptor{} |
| 50 | + randAsset.GroupKey.Witness = nil |
| 51 | + randAsset.ScriptKey.TweakedScriptKey = nil |
| 52 | + |
| 53 | + return randAsset |
| 54 | +} |
| 55 | + |
40 | 56 | // RandPacket generates a random virtual packet for testing purposes. |
41 | 57 | func RandPacket(t testing.TB, setVersion bool) *VPacket { |
42 | 58 | testPubKey := test.RandPubKey(t) |
@@ -66,16 +82,12 @@ func RandPacket(t testing.TB, setVersion bool) *VPacket { |
66 | 82 | testAsset := asset.RandAsset(t, asset.Normal) |
67 | 83 | testAsset.ScriptKey = inputScriptKey |
68 | 84 |
|
69 | | - testOutputAsset := asset.RandAsset(t, asset.Normal) |
70 | | - testOutputAsset.ScriptKey = asset.NewScriptKeyBip86(keyDesc) |
71 | | - |
72 | 85 | // The raw key won't be serialized within the asset, so let's blank it |
73 | 86 | // out here to get a fully, byte-by-byte comparable PSBT. |
74 | 87 | testAsset.GroupKey.RawKey = keychain.KeyDescriptor{} |
75 | 88 | testAsset.GroupKey.Witness = nil |
76 | | - testOutputAsset.GroupKey.RawKey = keychain.KeyDescriptor{} |
77 | | - testOutputAsset.GroupKey.Witness = nil |
78 | | - testOutputAsset.ScriptKey.TweakedScriptKey = nil |
| 89 | + |
| 90 | + testOutputAsset := RandAssetForPacket(t, asset.Normal, keyDesc) |
79 | 91 | leaf1 := txscript.TapLeaf{ |
80 | 92 | LeafVersion: txscript.BaseLeafVersion, |
81 | 93 | Script: []byte("not a valid script"), |
|
0 commit comments