@@ -574,6 +574,45 @@ var bindTests = []struct {
574
574
nil ,
575
575
nil ,
576
576
},
577
+ {
578
+ `NonExistentStruct` ,
579
+ `
580
+ contract NonExistentStruct {
581
+ function Struct() public view returns(uint256 a, uint256 b) {
582
+ return (10, 10);
583
+ }
584
+ }
585
+ ` ,
586
+ []string {`6080604052348015600f57600080fd5b5060888061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063d5f6622514602d575b600080fd5b6033604c565b6040805192835260208301919091528051918290030190f35b600a809156fea264697066735822beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef64736f6c6343decafe0033` },
587
+ []string {`[{"inputs":[],"name":"Struct","outputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"stateMutability":"pure","type":"function"}]` },
588
+ `
589
+ "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
590
+ "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends"
591
+ "github.com/XinFinOrg/XDPoSChain/common"
592
+ "github.com/XinFinOrg/XDPoSChain/core"
593
+ "github.com/XinFinOrg/XDPoSChain/params"
594
+ ` ,
595
+ `
596
+ // Create a simulator and wrap a non-deployed contract
597
+ sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{}, 10000000, params.TestXDPoSMockChainConfig)
598
+ defer sim.Close()
599
+
600
+ nonexistent, err := NewNonExistentStruct(common.Address{}, sim)
601
+ if err != nil {
602
+ t.Fatalf("Failed to access non-existent contract: %v", err)
603
+ }
604
+ // Ensure that contract calls fail with the appropriate error
605
+ if res, err := nonexistent.Struct(nil); err == nil {
606
+ t.Fatalf("Call succeeded on non-existent contract: %v", res)
607
+ } else if (err != bind.ErrNoCode) {
608
+ t.Fatalf("Error mismatch: have %v, want %v", err, bind.ErrNoCode)
609
+ }
610
+ ` ,
611
+ nil ,
612
+ nil ,
613
+ nil ,
614
+ nil ,
615
+ },
577
616
// Tests that gas estimation works for contracts with weird gas mechanics too.
578
617
{
579
618
`FunkyGasPattern` ,
0 commit comments