Skip to content

Commit 5b134c1

Browse files
authored
🔀 Merge pull request #191 from perun-network/189-fix-modified-params-id
[channel/test] Generate modified params with correct id
2 parents 08ca7b7 + 505f5b0 commit 5b134c1

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

channel/test/channeltest.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,42 +133,54 @@ func buildModifiedParams(p1, p2 *channel.Params, s *Setup) (ret []channel.Params
133133
// Modify complete Params
134134
{
135135
modParams := *p2
136-
ret = append(ret, modParams)
136+
ret = appendModParams(ret, modParams)
137137
}
138138
// Modify ChallengeDuration
139139
{
140140
modParams := *p1
141141
modParams.ChallengeDuration = p2.ChallengeDuration
142-
ret = append(ret, modParams)
142+
ret = appendModParams(ret, modParams)
143143
}
144144
// Modify Parts
145145
{
146146
// Modify complete Parts
147147
{
148148
modParams := *p1
149149
modParams.Parts = p2.Parts
150-
ret = append(ret, modParams)
150+
ret = appendModParams(ret, modParams)
151151
}
152152
// Modify Parts[0]
153153
{
154154
modParams := *p1
155155
modParams.Parts = make([]wallet.Address, len(p1.Parts))
156156
copy(modParams.Parts, p1.Parts)
157157
modParams.Parts[0] = s.RandomAddress()
158-
ret = append(ret, modParams)
158+
ret = appendModParams(ret, modParams)
159159
}
160160
}
161161
// Modify Nonce
162162
{
163163
modParams := *p1
164164
modParams.Nonce = p2.Nonce
165-
ret = append(ret, modParams)
165+
ret = appendModParams(ret, modParams)
166166
}
167167
}
168168

169169
return
170170
}
171171

172+
func appendModParams(a []channel.Params, modParams channel.Params) []channel.Params {
173+
p := channel.NewParamsUnsafe(
174+
modParams.ChallengeDuration,
175+
modParams.Parts,
176+
modParams.App,
177+
modParams.Nonce,
178+
modParams.LedgerChannel,
179+
modParams.VirtualChannel,
180+
)
181+
return append(a, *p)
182+
}
183+
172184
// buildModifiedStates returns a slice of States that are different from `s1` assuming that `s2` differs in
173185
// every member from `s1`.
174186
// `modifyApp` indicates whether the app should also be changed or not. In some cases (signature) it is desirable

0 commit comments

Comments
 (0)