Skip to content

Commit 4fb5735

Browse files
committed
Exercise conversion logic/handling of txnaccess.
1 parent 900fb04 commit 4fb5735

18 files changed

+835
-2
lines changed

api/handlers_test.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ func loadBlockFromFile(path string) generated.Block {
405405
return ret
406406
}
407407

408+
409+
410+
408411
func TestFetchTransactions(t *testing.T) {
409412
// Add in txnRows (with TxnBytes to parse), verify that they are properly serialized to generated.TransactionResponse
410413
tests := []struct {
@@ -662,6 +665,78 @@ func TestFetchTransactions(t *testing.T) {
662665
loadTransactionFromFile("test_resources/heartbeat.response"),
663666
},
664667
},
668+
{
669+
name: "Application txnAccess - Direct Address",
670+
txnBytes: [][]byte{
671+
loadResourceFileOrPanic("test_resources/txnaccess_address.txn"),
672+
},
673+
response: []generated.Transaction{
674+
loadTransactionFromFile("test_resources/txnaccess_address.response"),
675+
},
676+
},
677+
{
678+
name: "Application txnAccess - Direct App",
679+
txnBytes: [][]byte{
680+
loadResourceFileOrPanic("test_resources/txnaccess_app.txn"),
681+
},
682+
response: []generated.Transaction{
683+
loadTransactionFromFile("test_resources/txnaccess_app.response"),
684+
},
685+
},
686+
{
687+
name: "Application txnAccess - Direct Asset",
688+
txnBytes: [][]byte{
689+
loadResourceFileOrPanic("test_resources/txnaccess_asset.txn"),
690+
},
691+
response: []generated.Transaction{
692+
loadTransactionFromFile("test_resources/txnaccess_asset.response"),
693+
},
694+
},
695+
{
696+
name: "Application txnAccess - Asset Holding",
697+
txnBytes: [][]byte{
698+
loadResourceFileOrPanic("test_resources/txnaccess_holding.txn"),
699+
},
700+
response: []generated.Transaction{
701+
loadTransactionFromFile("test_resources/txnaccess_holding.response"),
702+
},
703+
},
704+
{
705+
name: "Application txnAccess - Local State",
706+
txnBytes: [][]byte{
707+
loadResourceFileOrPanic("test_resources/txnaccess_local.txn"),
708+
},
709+
response: []generated.Transaction{
710+
loadTransactionFromFile("test_resources/txnaccess_local.response"),
711+
},
712+
},
713+
{
714+
name: "Application txnAccess - Box Reference",
715+
txnBytes: [][]byte{
716+
loadResourceFileOrPanic("test_resources/txnaccess_box.txn"),
717+
},
718+
response: []generated.Transaction{
719+
loadTransactionFromFile("test_resources/txnaccess_box.response"),
720+
},
721+
},
722+
{
723+
name: "Application txnAccess - Multiple Types",
724+
txnBytes: [][]byte{
725+
loadResourceFileOrPanic("test_resources/txnaccess_multiple.txn"),
726+
},
727+
response: []generated.Transaction{
728+
loadTransactionFromFile("test_resources/txnaccess_multiple.response"),
729+
},
730+
},
731+
{
732+
name: "Application txnAccess - Empty Access Array",
733+
txnBytes: [][]byte{
734+
loadResourceFileOrPanic("test_resources/txnaccess_empty.txn"),
735+
},
736+
response: []generated.Transaction{
737+
loadTransactionFromFile("test_resources/txnaccess_empty.response"),
738+
},
739+
},
665740
}
666741

667742
// use for the branch below and createTxn helper func to add a new test case
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"application-transaction": {
3+
"access": [
4+
{
5+
"address": "AEBAGBAFAYDQQCIKBMGA2DQPCAIREEYUCULBOGAZDINRYHI6D4QDTYK3BA"
6+
}
7+
],
8+
"accounts": [],
9+
"application-args": [],
10+
"application-id": 123,
11+
"box-references": [],
12+
"foreign-apps": [],
13+
"foreign-assets": [],
14+
"global-state-schema": {
15+
"num-byte-slice": 0,
16+
"num-uint": 0
17+
},
18+
"local-state-schema": {
19+
"num-byte-slice": 0,
20+
"num-uint": 0
21+
},
22+
"on-completion": "noop"
23+
},
24+
"close-rewards": 0,
25+
"closing-amount": 0,
26+
"confirmed-round": 1,
27+
"fee": 1000,
28+
"first-valid": 1000,
29+
"id": "EIDBIPWWUU6OWP67SEJWF3YU3XEDSRA6RTXVY7E4HZKVIG26SBHQ",
30+
"intra-round-offset": 2,
31+
"last-valid": 2000,
32+
"receiver-rewards": 0,
33+
"round-time": 1756351776,
34+
"sender": "BIFQYDIOB4IBCEQTCQKRMFYYDENBWHA5DYPSAIJCEMSCKJRHFAURAA2UFY",
35+
"sender-rewards": 0,
36+
"signature": {},
37+
"tx-type": "appl"
38+
}

api/test_resources/txnaccess_address.txn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
��txn��al���d� 
2+
 �apid{�fee��fv��lv�Уsnd�
3+
 !"#$%&'()�type�appl
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"application-transaction": {
3+
"access": [
4+
{
5+
"application-id": 456
6+
}
7+
],
8+
"accounts": [],
9+
"application-args": [],
10+
"application-id": 123,
11+
"box-references": [],
12+
"foreign-apps": [],
13+
"foreign-assets": [],
14+
"global-state-schema": {
15+
"num-byte-slice": 0,
16+
"num-uint": 0
17+
},
18+
"local-state-schema": {
19+
"num-byte-slice": 0,
20+
"num-uint": 0
21+
},
22+
"on-completion": "noop"
23+
},
24+
"close-rewards": 0,
25+
"closing-amount": 0,
26+
"confirmed-round": 1,
27+
"fee": 1000,
28+
"first-valid": 1000,
29+
"id": "PUT6WBOSVADXHIPJ7THPATLMMCRIN7E63CGXBCDU6X4L6KTDJ5HQ",
30+
"intra-round-offset": 2,
31+
"last-valid": 2000,
32+
"receiver-rewards": 0,
33+
"round-time": 1756351776,
34+
"sender": "BIFQYDIOB4IBCEQTCQKRMFYYDENBWHA5DYPSAIJCEMSCKJRHFAURAA2UFY",
35+
"sender-rewards": 0,
36+
"signature": {},
37+
"tx-type": "appl"
38+
}

api/test_resources/txnaccess_app.txn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
��txn��al���p�Ȥapid{�fee��fv��lv�Уsnd�
2+
 !"#$%&'()�type�appl
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"application-transaction": {
3+
"access": [
4+
{
5+
"asset-id": 789
6+
}
7+
],
8+
"accounts": [],
9+
"application-args": [],
10+
"application-id": 123,
11+
"box-references": [],
12+
"foreign-apps": [],
13+
"foreign-assets": [],
14+
"global-state-schema": {
15+
"num-byte-slice": 0,
16+
"num-uint": 0
17+
},
18+
"local-state-schema": {
19+
"num-byte-slice": 0,
20+
"num-uint": 0
21+
},
22+
"on-completion": "noop"
23+
},
24+
"close-rewards": 0,
25+
"closing-amount": 0,
26+
"confirmed-round": 1,
27+
"fee": 1000,
28+
"first-valid": 1000,
29+
"id": "WPHHOTRIKBSP76WBJT2INGILDJ55UNBUUSWUM3NZENHWE5EUWPNQ",
30+
"intra-round-offset": 2,
31+
"last-valid": 2000,
32+
"receiver-rewards": 0,
33+
"round-time": 1756351776,
34+
"sender": "BIFQYDIOB4IBCEQTCQKRMFYYDENBWHA5DYPSAIJCEMSCKJRHFAURAA2UFY",
35+
"sender-rewards": 0,
36+
"signature": {},
37+
"tx-type": "appl"
38+
}

api/test_resources/txnaccess_asset.txn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
��txn��al���s��apid{�fee��fv��lv�Уsnd�
2+
 !"#$%&'()�type�appl
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"application-transaction": {
3+
"access": [
4+
{
5+
"application-id": 400
6+
},
7+
{
8+
"box": {
9+
"app": 400,
10+
"name": "dGVzdC1ib3gtbmFtZQ=="
11+
}
12+
}
13+
],
14+
"accounts": [],
15+
"application-args": [],
16+
"application-id": 123,
17+
"box-references": [],
18+
"foreign-apps": [],
19+
"foreign-assets": [],
20+
"global-state-schema": {
21+
"num-byte-slice": 0,
22+
"num-uint": 0
23+
},
24+
"local-state-schema": {
25+
"num-byte-slice": 0,
26+
"num-uint": 0
27+
},
28+
"on-completion": "noop"
29+
},
30+
"close-rewards": 0,
31+
"closing-amount": 0,
32+
"confirmed-round": 1,
33+
"fee": 1000,
34+
"first-valid": 1000,
35+
"id": "WORMCJZTCUJZNOW7N2VUNWNKYSWIAMR4ENEUGBEMNKRD2RUGPCGA",
36+
"intra-round-offset": 2,
37+
"last-valid": 2000,
38+
"receiver-rewards": 0,
39+
"round-time": 1756351776,
40+
"sender": "BIFQYDIOB4IBCEQTCQKRMFYYDENBWHA5DYPSAIJCEMSCKJRHFAURAA2UFY",
41+
"sender-rewards": 0,
42+
"signature": {},
43+
"tx-type": "appl"
44+
}

api/test_resources/txnaccess_box.txn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
��txn��al���p����b��i�n�test-box-name�apid{�fee��fv��lv�Уsnd�
2+
 !"#$%&'()�type�appl
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"application-transaction": {
3+
"access": [],
4+
"accounts": [],
5+
"application-args": [],
6+
"application-id": 123,
7+
"box-references": [],
8+
"foreign-apps": [],
9+
"foreign-assets": [],
10+
"global-state-schema": {
11+
"num-byte-slice": 0,
12+
"num-uint": 0
13+
},
14+
"local-state-schema": {
15+
"num-byte-slice": 0,
16+
"num-uint": 0
17+
},
18+
"on-completion": "noop"
19+
},
20+
"close-rewards": 0,
21+
"closing-amount": 0,
22+
"confirmed-round": 1,
23+
"fee": 1000,
24+
"first-valid": 1000,
25+
"id": "TMYECGE5Q7HL7YKVN24Q4F7FN5JW6EAEWC4KYIYTEFCKT3SUIRXQ",
26+
"intra-round-offset": 2,
27+
"last-valid": 2000,
28+
"receiver-rewards": 0,
29+
"round-time": 1756351776,
30+
"sender": "BIFQYDIOB4IBCEQTCQKRMFYYDENBWHA5DYPSAIJCEMSCKJRHFAURAA2UFY",
31+
"sender-rewards": 0,
32+
"signature": {},
33+
"tx-type": "appl"
34+
}

0 commit comments

Comments
 (0)