1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
// Copyright (C) 2019-2023 Algorand, Inc.
// This file is part of go-algorand
//
// go-algorand is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// go-algorand is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.
package transactions
import (
"reflect"
"testing"
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/test/partitiontest"
)
func TestApplicationCallFieldsNotChanged(t *testing.T) {
partitiontest.PartitionTest(t)
af := ApplicationCallTxnFields{}
s := reflect.ValueOf(&af).Elem()
if s.NumField() != 13 {
t.Errorf("You added or removed a field from transactions.ApplicationCallTxnFields. " +
"Please ensure you have updated the Empty() method and then " +
"fix this test")
}
}
func TestApplicationCallFieldsEmpty(t *testing.T) {
partitiontest.PartitionTest(t)
a := require.New(t)
ac := ApplicationCallTxnFields{}
a.True(ac.Empty())
ac.ApplicationID = 1
a.False(ac.Empty())
ac.ApplicationID = 0
ac.OnCompletion = 1
a.False(ac.Empty())
ac.OnCompletion = 0
ac.ApplicationArgs = make([][]byte, 1)
a.False(ac.Empty())
ac.ApplicationArgs = nil
ac.Accounts = make([]basics.Address, 1)
a.False(ac.Empty())
ac.Accounts = nil
ac.ForeignApps = make([]basics.AppIndex, 1)
a.False(ac.Empty())
ac.ForeignApps = nil
ac.ForeignAssets = make([]basics.AssetIndex, 1)
a.False(ac.Empty())
ac.ForeignAssets = nil
ac.LocalStateSchema = basics.StateSchema{NumUint: 1}
a.False(ac.Empty())
ac.LocalStateSchema = basics.StateSchema{}
ac.Boxes = make([]BoxRef, 1)
a.False(ac.Empty())
ac.Boxes = nil
ac.GlobalStateSchema = basics.StateSchema{NumUint: 1}
a.False(ac.Empty())
ac.GlobalStateSchema = basics.StateSchema{}
ac.ApprovalProgram = []byte{1}
a.False(ac.Empty())
ac.ApprovalProgram = []byte{}
a.False(ac.Empty())
ac.ApprovalProgram = nil
ac.ClearStateProgram = []byte{1}
a.False(ac.Empty())
ac.ClearStateProgram = []byte{}
a.False(ac.Empty())
ac.ClearStateProgram = nil
a.True(ac.Empty())
}
func TestEncodedAppTxnAllocationBounds(t *testing.T) {
partitiontest.PartitionTest(t)
// ensure that all the supported protocols have value limits less or
// equal to their corresponding codec allocbounds
for protoVer, proto := range config.Consensus {
if proto.MaxAppArgs > encodedMaxApplicationArgs {
require.Failf(t, "proto.MaxAppArgs > encodedMaxApplicationArgs", "protocol version = %s", protoVer)
}
if proto.MaxAppTxnAccounts > encodedMaxAccounts {
require.Failf(t, "proto.MaxAppTxnAccounts > encodedMaxAccounts", "protocol version = %s", protoVer)
}
if proto.MaxAppTxnForeignApps > encodedMaxForeignApps {
require.Failf(t, "proto.MaxAppTxnForeignApps > encodedMaxForeignApps", "protocol version = %s", protoVer)
}
if proto.MaxAppTxnForeignAssets > encodedMaxForeignAssets {
require.Failf(t, "proto.MaxAppTxnForeignAssets > encodedMaxForeignAssets", "protocol version = %s", protoVer)
}
if proto.MaxAppBoxReferences > encodedMaxBoxes {
require.Failf(t, "proto.MaxAppBoxReferences > encodedMaxBoxes", "protocol version = %s", protoVer)
}
}
}
|