Skip to content

Commit

Permalink
upgraded TestAddDeclareTxn to Sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagodeev committed May 16, 2024
1 parent b05569d commit 8e3a253
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 40 deletions.
20 changes: 15 additions & 5 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,6 @@ func TestWaitForTransactionReceipt(t *testing.T) {
//
// none
func TestAddDeclareTxn(t *testing.T) {
// https://sepolia.voyager.online/tx/0x272ebd99f5d0a275b4bc26781f76c4c4e48050ce5f1c1ddafcdee48f0297255
if testEnv != "testnet" {
t.Skip("Skipping test as it requires a testnet environment")
}
Expand All @@ -1176,7 +1175,7 @@ func TestAddDeclareTxn(t *testing.T) {
require.NoError(t, err)

// Class Hash
content, err := os.ReadFile("./tests/hello_starknet_compiled.sierra.json")
content, err := os.ReadFile("./tests/hello_world_compiled.sierra.json")
require.NoError(t, err)

var class rpc.ContractClass
Expand All @@ -1186,7 +1185,7 @@ func TestAddDeclareTxn(t *testing.T) {
require.NoError(t, err)

// Compiled Class Hash
content2, err := os.ReadFile("./tests/hello_starknet_compiled.casm.json")
content2, err := os.ReadFile("./tests/hello_world_compiled.casm.json")
require.NoError(t, err)

var casmClass contracts.CasmClass
Expand All @@ -1198,7 +1197,7 @@ func TestAddDeclareTxn(t *testing.T) {
// require.NoError(t, err)

tx := rpc.DeclareTxnV2{
Nonce: utils.TestHexToFelt(t, "0x9"),
Nonce: utils.TestHexToFelt(t, "0xd"),
MaxFee: utils.TestHexToFelt(t, "0xc5cb22092551"),
Type: rpc.TransactionType_Declare,
Version: rpc.TransactionV2,
Expand All @@ -1214,7 +1213,18 @@ func TestAddDeclareTxn(t *testing.T) {
err = acnt.SignDeclareTransaction(context.Background(), &tx)
require.NoError(t, err)

resp, err := acnt.AddDeclareTransaction(context.Background(), tx)
broadcastTx := rpc.BroadcastDeclareTxnV2{
Nonce: tx.Nonce,
MaxFee: tx.MaxFee,
Type: tx.Type,
Version: tx.Version,
Signature: tx.Signature,
SenderAddress: tx.SenderAddress,
CompiledClassHash: tx.CompiledClassHash,
ContractClass: class,
}

resp, err := acnt.AddDeclareTransaction(context.Background(), broadcastTx)

if err != nil {
require.Equal(t, rpc.ErrDuplicateTx.Error(), err.Error(), "AddDeclareTransaction error not what expected")
Expand Down
36 changes: 1 addition & 35 deletions account/tests/hello_world_compiled.sierra.json
Original file line number Diff line number Diff line change
Expand Up @@ -803,39 +803,5 @@
}
]
},
"abi": [
{
"type": "impl",
"name": "HelloWorld",
"interface_name": "hello_world::HelloWorldInterface"
},
{
"type": "interface",
"name": "hello_world::HelloWorldInterface",
"items": [
{
"type": "function",
"name": "get_message",
"inputs": [],
"outputs": [
{
"type": "core::felt252"
}
],
"state_mutability": "view"
}
]
},
{
"type": "constructor",
"name": "constructor",
"inputs": []
},
{
"type": "event",
"name": "hello_world::hello_world_contract::Event",
"kind": "enum",
"variants": []
}
]
"abi": "[{\"type\":\"impl\",\"name\":\"HelloWorld\",\"interface_name\":\"hello_world::HelloWorldInterface\"},{\"type\":\"interface\",\"name\":\"hello_world::HelloWorldInterface\",\"items\":[{\"type\":\"function\",\"name\":\"get_message\",\"inputs\":[],\"outputs\":[{\"type\":\"core::felt252\"}],\"state_mutability\":\"view\"}]},{\"type\":\"constructor\",\"name\":\"constructor\",\"inputs\":[]},{\"type\":\"event\",\"name\":\"hello_world::hello_world_contract::Event\",\"kind\":\"enum\",\"variants\":[]}]"
}

0 comments on commit 8e3a253

Please sign in to comment.