1+ import http from "k6/http" ;
2+ import { check , sleep , group } from "k6" ;
3+ import { randomItem } from "https://jslib.k6.io/k6-utils/1.2.0/index.js" ;
4+ import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js" ;
5+
6+ export const options = {
7+ stages : [
8+ { duration : "30s" , target : 20 } ,
9+ { duration : "1m" , target : 20 } ,
10+ { duration : "30s" , target : 0 } ,
11+ ] ,
12+ thresholds : {
13+ http_req_duration : [ "p(95)<200" ] ,
14+ http_req_failed : [ "rate<0.01" ] ,
15+ checks : [ "rate==1.0" ] ,
16+ } ,
17+ } ;
18+
19+ const BASE_URL = __ENV . BASE_URL || "https://indexer.namada.tududes.com" ;
20+ const ADDRESSES = [
21+ "tnam1q893l8zdx48wcdg62mf9gy4klgq9rmvg9ss48rz7" ,
22+ "tnam1q8w3wpa2rh9qepzyn72923lkd9aepwnsucw4wcp7" ,
23+ "tnam1qqec0hwnhqss75ngqgh4jrjxwgzxq6c8u5sr03mg" ,
24+ "tnam1qz9g9w3mnre6ravw3wrxw5mpzv4vtajy8s0rm8af" ,
25+ ] ;
26+ const GOVERNANCE_PROPOSALS = [ 1 , 10 , 30 ] ;
27+
28+ export default function ( ) {
29+ group ( "Health Check" , function ( ) {
30+ const res = http . get ( `${ BASE_URL } /health` ) ;
31+ check ( res , { "Health check is 200" : ( r ) => r . status === 200 } ) ;
32+ } ) ;
33+
34+ sleep ( 1 ) ;
35+
36+ group ( "PoS Validator Endpoints" , function ( ) {
37+ const res = http . get ( `${ BASE_URL } /api/v1/pos/validator?page=1` , {
38+ tags : { name : "GetValidators" } ,
39+ } ) ;
40+ check ( res , { "Get validators is 200" : ( r ) => r . status === 200 } ) ;
41+ } ) ;
42+
43+ sleep ( 1 ) ;
44+
45+ group ( "PoS Rewards Endpoints" , function ( ) {
46+ const address = randomItem ( ADDRESSES ) ;
47+ const res = http . get ( `${ BASE_URL } /api/v1/pos/reward/${ address } ` , {
48+ tags : { name : "GetReward" } ,
49+ } ) ;
50+ check ( res , { "Get reward is 200" : ( r ) => r . status === 200 } ) ;
51+ } ) ;
52+
53+ sleep ( 1 ) ;
54+
55+ group ( "Governance proposal Endpoints" , function ( ) {
56+ const proposalId = randomItem ( GOVERNANCE_PROPOSALS ) ;
57+ const res = http . get (
58+ `${ BASE_URL } /api/v1/gov/proposal/${ proposalId } ` ,
59+ {
60+ tags : { name : "GetGovernanceProposal" } ,
61+ }
62+ ) ;
63+ check ( res , { "Get governance proposal is 200" : ( r ) => r . status === 200 } ) ;
64+ } ) ;
65+
66+ sleep ( 1 ) ;
67+
68+ group ( "Governance votes Endpoints" , function ( ) {
69+ const proposalId = randomItem ( GOVERNANCE_PROPOSALS ) ;
70+ const res = http . get (
71+ `${ BASE_URL } /api/v1/gov/proposal/${ proposalId } /votes` ,
72+ {
73+ tags : { name : "GetGovernanceVotes" } ,
74+ }
75+ ) ;
76+ check ( res , {
77+ "Get governance proposal votes is 200" : ( r ) => r . status === 200 ,
78+ } ) ;
79+ } ) ;
80+
81+ group ( "Account Balance Endpoints" , function ( ) {
82+ const address = randomItem ( ADDRESSES ) ;
83+ const res = http . get ( `${ BASE_URL } /api/v1/account/${ address } ` , {
84+ tags : { name : "GetAccountBalance" } ,
85+ } ) ;
86+ check ( res , { "Get account balance is 200" : ( r ) => r . status === 200 } ) ;
87+ } ) ;
88+
89+ sleep ( 1 ) ;
90+
91+ group ( "Masp Aggregated Endpoints" , function ( ) {
92+ const res = http . get ( `${ BASE_URL } /api/v1/masp/aggregates` , {
93+ tags : { name : "GetMaspAggregated" } ,
94+ } ) ;
95+ check ( res , { "Get masp aggregated is 200" : ( r ) => r . status === 200 } ) ;
96+ } ) ;
97+ }
98+
99+ export function handleSummary ( data ) {
100+ return {
101+ "summary.html" : htmlReport ( data ) ,
102+ } ;
103+ }
0 commit comments