Skip to content

Commit

Permalink
lint and test
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel committed Mar 17, 2024
1 parent f86989a commit c83b11d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go/enclave/components/sigverifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewSignatureValidator(seqID gethcommon.Address, storage storage.Storage) (*
}

// CheckSequencerSignature - verifies the signature against the registered sequencer
func (sigChecker *SignatureValidator) CheckSequencerSignature(headerHash gethcommon.Hash, sig []byte) error {
func (sigChecker *SignatureValidator) CheckSequencerSignature(_ gethcommon.Hash, sig []byte) error {
if sig == nil {
return fmt.Errorf("missing signature on batch")
}
Expand Down
10 changes: 10 additions & 0 deletions integration/datagenerator/wallet.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package datagenerator

import (
"crypto/ecdsa"
"encoding/hex"

"github.com/ethereum/go-ethereum/crypto"
"github.com/ten-protocol/go-ten/integration/common/testlog"

"github.com/ten-protocol/go-ten/go/wallet"
Expand All @@ -17,6 +19,14 @@ func RandomWallet(chainID int64) wallet.Wallet {
)
}

func RandomPrivateKey() *ecdsa.PrivateKey {
privKey, err := crypto.HexToECDSA(randomHex(32))
if err != nil {
panic(err)
}
return privKey
}

func randomHex(n int) string {
return hex.EncodeToString(RandomBytes(n))
}
2 changes: 1 addition & 1 deletion integration/smartcontract/debug_mgmt_contract_lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (d *debugMgmtContractLib) AwaitedIssueRollup(rollup common.ExtRollup, clien
return fmt.Errorf("rollup not stored in tree")
}

if !bytes.Equal(rollupElement.EnclaveID[:], rollup.Header.EnclaveID.Bytes()) {
if !bytes.Equal(rollupElement.Signature, rollup.Header.Signature) {
return fmt.Errorf("stored rollup does not match the generated rollup")
}

Expand Down
11 changes: 9 additions & 2 deletions integration/smartcontract/smartcontracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/ten-protocol/go-ten/go/common"
"github.com/ten-protocol/go-ten/go/common/constants"
"github.com/ten-protocol/go-ten/go/common/signature"
"github.com/ten-protocol/go-ten/go/ethadapter"
"github.com/ten-protocol/go-ten/go/ethadapter/mgmtcontractlib"
"github.com/ten-protocol/go-ten/go/wallet"
Expand Down Expand Up @@ -218,13 +219,19 @@ func attestedNodesCreateRollup(t *testing.T, mgmtContractLib *debugMgmtContractL
t.Error(err)
}

pk := datagenerator.RandomPrivateKey()
enclaveID := crypto.PubkeyToAddress(pk.PublicKey)

rollup := datagenerator.RandomRollup(block)
requesterID := &rollup.Header.EnclaveID
rollup.Header.Signature, err = signature.Sign(rollup.Hash().Bytes(), pk)
if err != nil {
t.Error(err)
}

// the aggregator starts the network
txData := mgmtContractLib.CreateInitializeSecret(
&ethadapter.L1InitializeSecretTx{
EnclaveID: requesterID,
EnclaveID: &enclaveID,
},
)

Expand Down

0 comments on commit c83b11d

Please sign in to comment.