@@ -11,14 +11,14 @@ import (
1111 "github.com/stretchr/testify/require"
1212)
1313
14- var fatErrorTestStructure = & FatErrorStructure {
15- MaxHops : 27 ,
16- MaxPayloadSize : 8 ,
14+ var attributableErrorTestStructure = & AttributableErrorStructure {
15+ HopCount : 27 ,
16+ FixedPayloadLen : 8 ,
1717}
1818
19- // TestFatOnionFailure checks the ability of sender of payment to decode the
20- // obfuscated onion error.
21- func TestFatOnionFailure (t * testing.T ) {
19+ // TestAttributableOnionFailure checks the ability of sender of payment to
20+ // decode the obfuscated onion error.
21+ func TestAttributableOnionFailure (t * testing.T ) {
2222 t .Parallel ()
2323
2424 // Create numHops random sphinx paymentPath.
@@ -33,8 +33,8 @@ func TestFatOnionFailure(t *testing.T) {
3333 require .NoError (t , err )
3434
3535 // Emulate creation of the obfuscator on node where error have occurred.
36- obfuscator := NewOnionFatErrorEncrypter (
37- sharedSecrets [len (errorPath )- 1 ], fatErrorTestStructure ,
36+ obfuscator := NewOnionAttributableErrorEncrypter (
37+ sharedSecrets [len (errorPath )- 1 ], attributableErrorTestStructure ,
3838 )
3939
4040 // Emulate the situation when last hop creates the onion failure
@@ -50,8 +50,8 @@ func TestFatOnionFailure(t *testing.T) {
5050 for i := len (errorPath ) - 2 ; i >= 0 ; i -- {
5151 // Emulate creation of the obfuscator on forwarding node which
5252 // propagates the onion failure.
53- obfuscator = NewOnionFatErrorEncrypter (
54- sharedSecrets [i ], fatErrorTestStructure ,
53+ obfuscator = NewOnionAttributableErrorEncrypter (
54+ sharedSecrets [i ], attributableErrorTestStructure ,
5555 )
5656
5757 intermediatePayload := [8 ]byte {byte (100 + i )}
@@ -64,10 +64,10 @@ func TestFatOnionFailure(t *testing.T) {
6464 }
6565
6666 // Emulate creation of the deobfuscator on the receiving onion error side.
67- deobfuscator := NewOnionFatErrorDecrypter (& Circuit {
67+ deobfuscator := NewOnionAttributableErrorDecrypter (& Circuit {
6868 SessionKey : sessionKey ,
6969 PaymentPath : paymentPath ,
70- }, fatErrorTestStructure )
70+ }, attributableErrorTestStructure )
7171
7272 // Emulate that sender node receive the failure message and trying to
7373 // unwrap it, by applying obfuscation and checking the hmac.
@@ -103,22 +103,24 @@ func TestOnionFailureCorruption(t *testing.T) {
103103 require .NoError (t , err )
104104
105105 // Emulate creation of the obfuscator on node where error have occurred.
106- obfuscator := NewOnionFatErrorEncrypter (
107- sharedSecrets [len (errorPath )- 1 ], fatErrorTestStructure ,
106+ obfuscator := NewOnionAttributableErrorEncrypter (
107+ sharedSecrets [len (errorPath )- 1 ], attributableErrorTestStructure ,
108108 )
109109
110110 // Emulate the situation when last hop creates the onion failure
111111 // message and send it back.
112112 payload := [8 ]byte {1 }
113- obfuscatedData , err := obfuscator .EncryptError (true , failureData , payload [:])
113+ obfuscatedData , err := obfuscator .EncryptError (
114+ true , failureData , payload [:],
115+ )
114116 require .NoError (t , err )
115117
116118 // Emulate that failure message is backward obfuscated on every hop.
117119 for i := len (errorPath ) - 2 ; i >= 0 ; i -- {
118120 // Emulate creation of the obfuscator on forwarding node which
119121 // propagates the onion failure.
120- obfuscator = NewOnionFatErrorEncrypter (
121- sharedSecrets [i ], fatErrorTestStructure ,
122+ obfuscator = NewOnionAttributableErrorEncrypter (
123+ sharedSecrets [i ], attributableErrorTestStructure ,
122124 )
123125
124126 payload := [8 ]byte {byte (100 + i )}
@@ -135,10 +137,10 @@ func TestOnionFailureCorruption(t *testing.T) {
135137 }
136138
137139 // Emulate creation of the deobfuscator on the receiving onion error side.
138- deobfuscator := NewOnionFatErrorDecrypter (& Circuit {
140+ deobfuscator := NewOnionAttributableErrorDecrypter (& Circuit {
139141 SessionKey : sessionKey ,
140142 PaymentPath : paymentPath ,
141- }, fatErrorTestStructure )
143+ }, attributableErrorTestStructure )
142144
143145 // Emulate that sender node receive the failure message and trying to
144146 // unwrap it, by applying obfuscation and checking the hmac.
@@ -163,10 +165,10 @@ type specVector struct {
163165
164166// TestOnionFailureSpecVector checks that onion error corresponds to the
165167// specification.
166- func TestFatOnionFailureSpecVector (t * testing.T ) {
168+ func TestAttributableFailureSpecVector (t * testing.T ) {
167169 t .Parallel ()
168170
169- vectorBytes , err := os .ReadFile ("testdata/fat_error .json" )
171+ vectorBytes , err := os .ReadFile ("testdata/attributable_error .json" )
170172 require .NoError (t , err )
171173
172174 var vector specVector
@@ -191,8 +193,9 @@ func TestFatOnionFailureSpecVector(t *testing.T) {
191193 expectedSharedSecret , err := hex .DecodeString (test .SharedSecret )
192194 require .NoError (t , err )
193195
194- obfuscator := NewOnionFatErrorEncrypter (
195- sharedSecrets [len (sharedSecrets )- 1 - i ], fatErrorTestStructure ,
196+ obfuscator := NewOnionAttributableErrorEncrypter (
197+ sharedSecrets [len (sharedSecrets )- 1 - i ],
198+ attributableErrorTestStructure ,
196199 )
197200
198201 require .Equal (t , expectedSharedSecret , obfuscator .sharedSecret [:])
@@ -222,10 +225,10 @@ func TestFatOnionFailureSpecVector(t *testing.T) {
222225 require .Equal (t , expectedEncryptErrorData , obfuscatedData )
223226 }
224227
225- deobfuscator := NewOnionFatErrorDecrypter (& Circuit {
228+ deobfuscator := NewOnionAttributableErrorDecrypter (& Circuit {
226229 SessionKey : sessionKey ,
227230 PaymentPath : paymentPath ,
228- }, fatErrorTestStructure )
231+ }, attributableErrorTestStructure )
229232
230233 // Emulate that sender node receives the failure message and trying to
231234 // unwrap it, by applying obfuscation and checking the hmac.
@@ -244,19 +247,19 @@ func TestFatOnionFailureSpecVector(t *testing.T) {
244247 require .Equal (t , len (paymentPath ), decryptedError .SenderIdx )
245248}
246249
247- // TestFatOnionFailureZeroesMessage checks that a garbage failure is attributed
248- // to the first hop.
249- func TestFatOnionFailureZeroesMessage (t * testing.T ) {
250+ // TestAttributableOnionFailureZeroesMessage checks that a garbage failure is
251+ // attributed to the first hop.
252+ func TestAttributableOnionFailureZeroesMessage (t * testing.T ) {
250253 t .Parallel ()
251254
252255 // Create numHops random sphinx paymentPath.
253256 sessionKey , paymentPath := generateRandomPath (t )
254257
255258 // Emulate creation of the deobfuscator on the receiving onion error side.
256- deobfuscator := NewOnionFatErrorDecrypter (& Circuit {
259+ deobfuscator := NewOnionAttributableErrorDecrypter (& Circuit {
257260 SessionKey : sessionKey ,
258261 PaymentPath : paymentPath ,
259- }, fatErrorTestStructure )
262+ }, attributableErrorTestStructure )
260263
261264 // Emulate that sender node receive the failure message and trying to
262265 // unwrap it, by applying obfuscation and checking the hmac.
@@ -268,19 +271,19 @@ func TestFatOnionFailureZeroesMessage(t *testing.T) {
268271 require .Equal (t , 1 , decryptedError .SenderIdx )
269272}
270273
271- // TestFatOnionFailureShortMessage checks that too short failure is attributed
272- // to the first hop.
273- func TestFatOnionFailureShortMessage (t * testing.T ) {
274+ // TestAttributableOnionFailureShortMessage checks that too short failure is
275+ // attributed to the first hop.
276+ func TestAttributableOnionFailureShortMessage (t * testing.T ) {
274277 t .Parallel ()
275278
276279 // Create numHops random sphinx paymentPath.
277280 sessionKey , paymentPath := generateRandomPath (t )
278281
279282 // Emulate creation of the deobfuscator on the receiving onion error side.
280- deobfuscator := NewOnionFatErrorDecrypter (& Circuit {
283+ deobfuscator := NewOnionAttributableErrorDecrypter (& Circuit {
281284 SessionKey : sessionKey ,
282285 PaymentPath : paymentPath ,
283- }, fatErrorTestStructure )
286+ }, attributableErrorTestStructure )
284287
285288 // Emulate that sender node receive the failure message and trying to
286289 // unwrap it, by applying obfuscation and checking the hmac.
0 commit comments