1
+ import { Match , Template } from "aws-cdk-lib/assertions" ;
2
+ import * as cdk from "aws-cdk-lib" ;
3
+ import * as dotenv from "dotenv" ;
4
+ import * as config from "../lib/config/XRPConfig" ;
5
+ import { XRPCommonStack } from "../lib/common-stack" ;
6
+ import { XRPSingleNodeStack } from "../lib/single-node-stack" ;
7
+
8
+ dotenv . config ( { path : './test/.env-test' } ) ;
9
+
10
+ describe ( "SolanaSingleNodeStack" , ( ) => {
11
+ test ( "synthesizes the way we expect" , ( ) => {
12
+ const app = new cdk . App ( ) ;
13
+ const xrpCommonStack = new XRPCommonStack ( app , "xrp-common" , {
14
+ env : { account : config . baseConfig . accountId , region : config . baseConfig . region } ,
15
+ stackName : `xrp-nodes-common` ,
16
+ } ) ;
17
+
18
+ // Create the XRPSingleNodeStack.
19
+ const xrpSingleNodeStack = new XRPSingleNodeStack ( app , "XRP-sync-node" , {
20
+ env : { account : config . baseConfig . accountId , region : config . baseConfig . region } ,
21
+ stackName : `XRP-single-node` ,
22
+ instanceType : config . baseNodeConfig . instanceType ,
23
+ instanceCpuType : config . baseNodeConfig . instanceCpuType ,
24
+ dataVolume : config . baseNodeConfig . dataVolume ,
25
+ hubNetworkID : config . baseNodeConfig . hubNetworkID ,
26
+ instanceRole : xrpCommonStack . instanceRole ,
27
+ } ) ;
28
+
29
+ // Prepare the stack for assertions.
30
+ const template = Template . fromStack ( xrpSingleNodeStack ) ;
31
+
32
+ // Has EC2 instance security group.
33
+ template . hasResourceProperties ( "AWS::EC2::SecurityGroup" , {
34
+ GroupDescription : Match . anyValue ( ) ,
35
+ VpcId : Match . anyValue ( ) ,
36
+ SecurityGroupEgress : [
37
+ {
38
+ "CidrIp" : "0.0.0.0/0" ,
39
+ "Description" : "Allow all outbound traffic by default" ,
40
+ "IpProtocol" : "-1"
41
+ }
42
+ ] ,
43
+ SecurityGroupIngress : [
44
+ {
45
+ "CidrIp" : "0.0.0.0/0" ,
46
+ "Description" : "P2P protocols" ,
47
+ "FromPort" : 51235 ,
48
+ "IpProtocol" : "tcp" ,
49
+ "ToPort" : 51235
50
+ } ,
51
+ {
52
+ "CidrIp" : "0.0.0.0/0" ,
53
+ "Description" : "P2P protocols" ,
54
+ "FromPort" : 2459 ,
55
+ "IpProtocol" : "tcp" ,
56
+ "ToPort" : 2459
57
+ } ,
58
+ {
59
+ "CidrIp" : "1.2.3.4/5" ,
60
+ "Description" : "RPC port HTTP (user access needs to be restricted. Allowed access only from internal IPs)" ,
61
+ "FromPort" : 6005 ,
62
+ "IpProtocol" : "tcp" ,
63
+ "ToPort" : 6005
64
+ }
65
+ ]
66
+ } )
67
+
68
+ // Has EC2 instance with node configuration
69
+ template . hasResourceProperties ( "AWS::EC2::Instance" , {
70
+ AvailabilityZone : Match . anyValue ( ) ,
71
+ UserData : Match . anyValue ( ) ,
72
+ BlockDeviceMappings : [
73
+ {
74
+ DeviceName : "/dev/xvda" ,
75
+ Ebs : {
76
+ DeleteOnTermination : true ,
77
+ Encrypted : true ,
78
+ Iops : 3000 ,
79
+ VolumeSize : 46 ,
80
+ VolumeType : "gp3"
81
+ }
82
+ }
83
+ ] ,
84
+ IamInstanceProfile : Match . anyValue ( ) ,
85
+ ImageId : Match . anyValue ( ) ,
86
+ InstanceType : "r7a.12xlarge" ,
87
+ Monitoring : true ,
88
+ PropagateTagsToVolumeOnCreation : true ,
89
+ SecurityGroupIds : Match . anyValue ( ) ,
90
+ SubnetId : Match . anyValue ( ) ,
91
+ } )
92
+
93
+ // Has EBS data volume.
94
+ template . hasResourceProperties ( "AWS::EC2::Volume" , {
95
+ AvailabilityZone : Match . anyValue ( ) ,
96
+ Encrypted : true ,
97
+ Iops : 12000 ,
98
+ MultiAttachEnabled : false ,
99
+ Size : 2000 ,
100
+ Throughput : 700 ,
101
+ VolumeType : "gp3"
102
+ } )
103
+
104
+ // Has EBS data volume attachment.
105
+ template . hasResourceProperties ( "AWS::EC2::VolumeAttachment" , {
106
+ Device : "/dev/sdf" ,
107
+ InstanceId : Match . anyValue ( ) ,
108
+ VolumeId : Match . anyValue ( ) ,
109
+ } )
110
+
111
+ // Has CloudWatch dashboard.
112
+ template . hasResourceProperties ( "AWS::CloudWatch::Dashboard" , {
113
+ DashboardBody : Match . anyValue ( ) ,
114
+ DashboardName : { "Fn::Join" : [ "" , [ "XRP-single-node-" , { "Ref" : Match . anyValue ( ) } ] ] }
115
+ } )
116
+
117
+ } ) ;
118
+ } ) ;
0 commit comments