Skip to content

Conversation

@cce
Copy link
Contributor

@cce cce commented Mar 16, 2022

Summary

Now that the consensus upgrade for #3031 is complete this pushes a couple of unit tests related to signatures that were not valid before the batch verification upgrade, but are valid now.

Related: #3781

Test Plan

Adds two new tests.

@cce cce force-pushed the weird-ed25519-signatures branch from 56f0852 to e50e8a7 Compare March 16, 2022 21:39
@cce cce requested review from algorandskiy, id-ms and jannotti March 25, 2022 16:44
Copy link
Contributor

@id-ms id-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, the purpose of those tests is to check ed25519verify TEAL opcode under specially crafted public keys, right?
if so, what is the difference between those two tests? (I do understand that they have different logic, but this is not the focus of the test)

Is there a way to break one test without the other?

Copy link
Contributor

@jannotti jannotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good, willing to merge as is, let me know if you want to make any of the changes I mentioned. (the sb trace is probably the most worthwhile)

var txn transactions.SignedTxn
txn.Lsig.Logic = ops.Program
txn.Lsig.Args = [][]byte{data[:], vec[2], vec[1]}
sb := strings.Builder{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where you're putting sb in to trace. But you shouldn't have to anyway. defaultEvalParams inserts a string.Builder for you, so just change to evalParams.Trace.

evalParams.Proto.EnableBatchVerification = tc.enableBatchVerification
pass, err := EvalSignature(0, evalParams)
require.Equal(t, tc.valid, pass, "trace %s", sb.String())
t.Log(sb.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to Log the trace only if the test is about to fail, so the output is less cluttered when something else fails.

(== (txn Amount) 2000000))
)
*/
ops, err := AssembleStringWithVersion(`arg 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to use testProg for assembling in tests. It checks the error for you and does not return it, it disassembles and reassembles to check equality giving us more tests for free, and does some logging if things don't work out.

@cce
Copy link
Contributor Author

cce commented Jun 21, 2022

From my understanding, the purpose of those tests is to check ed25519verify TEAL opcode under specially crafted public keys, right?
if so, what is the difference between those two tests? (I do understand that they have different logic, but this is not the focus of the test)
Is there a way to break one test without the other?

There is no difference between the tests from the POV of the ed25519verify opcode operation, in the second one I was working on a transaction that would result in an account balance change, but it is not necessary if we want to just assert the new ed25519 behavior.

@cce
Copy link
Contributor Author

cce commented Sep 10, 2022

Unnecessary after #3781 merged

@cce cce closed this Sep 10, 2022
@cce cce deleted the weird-ed25519-signatures branch September 10, 2022 01:04
@cce cce restored the weird-ed25519-signatures branch September 10, 2022 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants