Skip to content

Commit

Permalink
unit-tests fix
Browse files Browse the repository at this point in the history
Signed-off-by: Angelo De Caro <[email protected]>
  • Loading branch information
adecaro committed Nov 22, 2024
1 parent f8048a6 commit 9c08585
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions token/services/network/common/rws/translator/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ func (w *Translator) checkIssue(issue IssueAction) error {
}

func (w *Translator) checkTransfer(t TransferAction) error {
inputs := t.GetInputs()

// check inputs

// we must check that the serial number does not exist, if any are in the action
Expand All @@ -222,10 +220,14 @@ func (w *Translator) checkTransfer(t TransferAction) error {
}

// we must check that the serial number for serialized inputs must exist, if any are in the action
inputs := t.GetInputs()
serializedInputs, err := t.GetSerializedInputs()
if err != nil {
return errors.Wrapf(err, "failed to get serialized inputs")
}
if len(serializedInputs) != len(inputs) {
return errors.Errorf("inputs and serialized inputs length mismatch")
}
for i, input := range inputs {
key, err := w.KeyTranslator.CreateOutputSNKey(input.TxId, input.Index, serializedInputs[i])
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ var _ = Describe("Translator", func() {
fakeRWSet.GetStateReturnsOnCall(0, nil, nil)
fakeRWSet.GetStateReturnsOnCall(1, nil, nil)
fakeRWSet.GetStateReturnsOnCall(2, nil, nil)
fakeRWSet.GetStateReturnsOnCall(3, []byte("s3"), nil)
fakeRWSet.GetStateReturnsOnCall(4, []byte("s4"), nil)
fakeRWSet.GetStateReturnsOnCall(5, []byte("s5"), nil)
faketransfer.GetInputsReturns([]*token.ID{{TxId: "key1"}, {TxId: "key2"}, {TxId: "key3"}})
faketransfer.GetSerializedInputsReturns([][]byte{[]byte("i1"), []byte("i2"), []byte("i3")}, nil)
faketransfer.GetSerialNumbersReturns(sn)
faketransfer.NumOutputsReturns(2)
faketransfer.IsGraphHidingReturns(true)
Expand Down

0 comments on commit 9c08585

Please sign in to comment.