Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Nov 24, 2023
1 parent 29eb67e commit 155a611
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 83 deletions.
9 changes: 0 additions & 9 deletions account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
74 changes: 0 additions & 74 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 155a611

Please sign in to comment.