Skip to content

Commit 66836e6

Browse files
authored
test: add XDR generator snapshot tests. (#767)
1 parent 3610dc6 commit 66836e6

109 files changed

Lines changed: 7830 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: XDR Generator Snapshot Test
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- "xdr-generator/**"
8+
- "Makefile"
9+
- ".github/workflows/xdr-generator-snapshot-test.yml"
10+
pull_request:
11+
paths:
12+
- "xdr-generator/**"
13+
- "Makefile"
14+
- ".github/workflows/xdr-generator-snapshot-test.yml"
15+
16+
jobs:
17+
snapshot-test:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Run XDR generator snapshot tests
22+
run: make xdr-generator-test

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ xdr/Stellar-exporter.x
1616
# stellar-xdr commit to use, see https://github.com/stellar/stellar-xdr
1717
XDR_COMMIT=4b7a2ef7931ab2ca2499be68d849f38190b443ca
1818

19-
.PHONY: xdr xdr-clean xdr-update
19+
.PHONY: xdr xdr-clean xdr-update xdr-generator-test xdr-generator-update-snapshots
2020

2121
xdr-generate: $(XDRS)
2222
docker run --rm -v $$PWD:/wd -w /wd ruby:3.4 /bin/bash -c '\
@@ -33,3 +33,15 @@ xdr-clean:
3333
find src/main/java/org/stellar/sdk/xdr -type f -name "*.java" ! -name "package-info.java" -delete
3434

3535
xdr-update: xdr-clean xdr-generate
36+
37+
xdr-generator-test:
38+
docker run --rm -v $$PWD:/wd -w /wd ruby:3.4 /bin/bash -c '\
39+
cd xdr-generator && \
40+
bundle install --quiet && \
41+
bundle exec ruby test/generator_snapshot_test.rb'
42+
43+
xdr-generator-update-snapshots:
44+
docker run --rm -v $$PWD:/wd -w /wd ruby:3.4 /bin/bash -c '\
45+
cd xdr-generator && \
46+
bundle install --quiet && \
47+
UPDATE_SNAPSHOTS=1 bundle exec ruby test/generator_snapshot_test.rb'

xdr-generator/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ gem "benchmark"
88
gem "bigdecimal"
99
gem "logger"
1010
gem "mutex_m"
11+
12+
gem "minitest"

xdr-generator/Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ DEPENDENCIES
4848
benchmark
4949
bigdecimal
5050
logger
51+
minitest
5152
mutex_m
5253
xdrgen!
5354

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
enum AccountFlags
2+
{ // masks for each flag
3+
AUTH_REQUIRED_FLAG = 0x1
4+
};
5+
6+
/* AccountEntry
7+
8+
Main entry representing a user in Stellar. All transactions are performed
9+
using an account.
10+
11+
Other ledger entries created require an account.
12+
13+
*/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const FOO = 1;
2+
3+
typedef int TestArray[FOO];
4+
typedef int TestArray2<FOO>;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
enum MessageType
2+
{
3+
ERROR_MSG,
4+
HELLO,
5+
DONT_HAVE,
6+
7+
GET_PEERS, // gets a list of peers this guy knows about
8+
PEERS,
9+
10+
GET_TX_SET, // gets a particular txset by hash
11+
TX_SET,
12+
13+
GET_VALIDATIONS, // gets validations for a given ledger hash
14+
VALIDATIONS,
15+
16+
TRANSACTION, //pass on a tx you have heard about
17+
JSON_TRANSACTION,
18+
19+
// FBA
20+
GET_FBA_QUORUMSET,
21+
FBA_QUORUMSET,
22+
FBA_MESSAGE
23+
};
24+
25+
enum Color {
26+
RED=0,
27+
GREEN=1,
28+
BLUE=2
29+
};
30+
31+
32+
enum Color2 {
33+
RED2=RED,
34+
GREEN2=1,
35+
BLUE2=2
36+
};
37+
38+
enum Color3 {
39+
RED_1=1,
40+
RED_2_TWO=2,
41+
RED_3=3
42+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
enum UnionKey {
2+
ONE = 1,
3+
TWO = 2,
4+
OFFER = 3
5+
};
6+
7+
typedef int Foo;
8+
9+
union MyUnion switch (UnionKey type)
10+
{
11+
case ONE:
12+
struct {
13+
int someInt;
14+
} one;
15+
16+
case TWO:
17+
struct {
18+
int someInt;
19+
Foo foo;
20+
} two;
21+
22+
case OFFER:
23+
void;
24+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
typedef int Arr[2];
2+
3+
struct HasOptions
4+
{
5+
int* firstOption;
6+
int *secondOption;
7+
Arr *thirdOption;
8+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
typedef hyper int64;
2+
3+
struct MyStruct
4+
{
5+
int someInt;
6+
int64 aBigInt;
7+
opaque someOpaque[10];
8+
string someString<>;
9+
string maxString<100>;
10+
};

0 commit comments

Comments
 (0)