From 155a61199c9b68da9508531a8eb73afa58ec776b Mon Sep 17 00:00:00 2001 From: rianhughes Date: Fri, 24 Nov 2023 10:00:16 +0200 Subject: [PATCH] tidy --- account/account.go | 9 ----- account/account_test.go | 74 ----------------------------------------- 2 files changed, 83 deletions(-) diff --git a/account/account.go b/account/account.go index 1402dd07..61eaa788 100644 --- a/account/account.go +++ b/account/account.go @@ -460,15 +460,6 @@ func (account *Account) TransactionHashDeclare(tx rpc.DeclareTxnType) (*felt.Fel return nil, err } - _, err = txn.ResourceBounds.L1Gas.Bytes(rpc.ResourceL1Gas) - if err != nil { - return nil, err - } - _, err = txn.ResourceBounds.L2Gas.Bytes(rpc.ResourceL2Gas) - if err != nil { - return nil, err - } - tipAndResourceHash, err := tipAndResourcesHash(tipUint64, txn.ResourceBounds) if err != nil { return nil, err diff --git a/account/account_test.go b/account/account_test.go index 18c4cacb..78dfece1 100644 --- a/account/account_test.go +++ b/account/account_test.go @@ -643,80 +643,6 @@ func TestAddDeployAccountDevnet(t *testing.T) { require.NotNil(t, resp, "AddDeployAccountTransaction resp not nil") } -// TestTransactionHashDeployAccountTestnet tests the TransactionHashDeployAccount function when using the testnet environment. -// -// It creates a client and provider, initializes the required addresses and keys, and sets up the transaction parameters. -// It then precomputes the address and calculates the hash of the transaction. -// Finally, it verifies that the calculated hash matches the expected hash. -// -// Parameters: -// - t: is the testing framework -// -// Returns: -// -// none -func TestTransactionHashDeployAccountTestnet(t *testing.T) { - - if testEnv != "testnet" { - t.Skip("Skipping test as it requires a testnet environment") - } - - client, err := rpc.NewClient(base) - require.NoError(t, err, "Error in rpc.NewClient") - provider := rpc.NewProvider(client) - - AccountAddress := utils.TestHexToFelt(t, "0x0088d0038623a89bf853c70ea68b1062ccf32b094d1d7e5f924cda8404dc73e1") - PubKey := utils.TestHexToFelt(t, "0x7ed3c6482e12c3ef7351214d1195ee7406d814af04a305617599ff27be43883") - PrivKey := utils.TestHexToFelt(t, "0x07514c4f0de1f800b0b0c7377ef39294ce218a7abd9a1c9b6aa574779f7cdc6a") - - ks := account.NewMemKeystore() - fakePrivKeyBI, ok := new(big.Int).SetString(PrivKey.String(), 0) - require.True(t, ok) - ks.Put(PubKey.String(), fakePrivKeyBI) - - acnt, err := account.NewAccount(provider, AccountAddress, PubKey.String(), ks) - require.NoError(t, err) - - classHash := utils.TestHexToFelt(t, "0x3131fa018d520a037686ce3efddeab8f28895662f019ca3ca18a626650f7d1e") - - type testSetType struct { - Txn rpc.DeployAccountTxn - ExpectedPrecomputedAddress *felt.Felt - ExpectedHash *felt.Felt - ExpectedErr error - } - testSet := map[string][]testSetType{ - "testnet": {{ - Txn: rpc.DeployAccountTxn{ - Nonce: &felt.Zero, - MaxFee: utils.TestHexToFelt(t, "0x105ef39b2000"), - Type: rpc.TransactionType_DeployAccount, - Version: rpc.TransactionV1, - Signature: []*felt.Felt{}, - ClassHash: classHash, - ContractAddressSalt: utils.TestHexToFelt(t, "0x7ed3c6482e12c3ef7351214d1195ee7406d814af04a305617599ff27be43883"), - ConstructorCalldata: []*felt.Felt{ - utils.TestHexToFelt(t, "0x5aa23d5bb71ddaa783da7ea79d405315bafa7cf0387a74f4593578c3e9e6570"), - utils.TestHexToFelt(t, "0x2dd76e7ad84dbed81c314ffe5e7a7cacfb8f4836f01af4e913f275f89a3de1a"), - utils.TestHexToFelt(t, "0x1"), - utils.TestHexToFelt(t, "0x7ed3c6482e12c3ef7351214d1195ee7406d814af04a305617599ff27be43883"), - }, - }, - ExpectedPrecomputedAddress: utils.TestHexToFelt(t, "0x88d0038623a89bf853c70ea68b1062ccf32b094d1d7e5f924cda8404dc73e1"), - ExpectedHash: utils.TestHexToFelt(t, "0x5b6b5927cd70ad7a80efdbe898244525871875c76540b239f6730118598b9cb"), - ExpectedErr: nil, - }, - }}[testEnv] - for _, test := range testSet { - precomputedAddress, err := acnt.PrecomputeAddress(&felt.Zero, test.Txn.ContractAddressSalt, classHash, test.Txn.ConstructorCalldata) - require.Equal(t, test.ExpectedPrecomputedAddress.String(), precomputedAddress.String(), "Error with calulcating PrecomputeAddress") - - hash, err := acnt.TransactionHashDeployAccount(test.Txn, precomputedAddress) - require.NoError(t, err, "TransactionHashDeployAccount gave an Error") - require.Equal(t, test.ExpectedHash.String(), hash.String(), "Error with calulcating TransactionHashDeployAccount") - } -} - // TestTransactionHashDeclare tests the TransactionHashDeclare function. // // This function verifies that the TransactionHashDeclare function returns the