|
| 1 | +package bridge |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "github.com/Gravity-Tech/gravity-node-data-extractor/v2/extractors" |
| 6 | + "github.com/Gravity-Tech/gravity-node-data-extractor/v2/helpers" |
| 7 | + "testing" |
| 8 | +) |
| 9 | + |
| 10 | +func TestErgToErgExtractionBridge_Configure(t *testing.T) { |
| 11 | + type fields struct { |
| 12 | + config ConfigureCommand |
| 13 | + configured bool |
| 14 | + ergClientSource *helpers.ErgClient |
| 15 | + ergClientTarget *helpers.ErgClient |
| 16 | + } |
| 17 | + type args struct { |
| 18 | + config ConfigureCommand |
| 19 | + } |
| 20 | + tests := []struct { |
| 21 | + name string |
| 22 | + fields fields |
| 23 | + args args |
| 24 | + wantErr bool |
| 25 | + }{ |
| 26 | + {name: "already configured", fields: fields{configured: true}, args: args{}, wantErr: true}, |
| 27 | + } |
| 28 | + for _, tt := range tests { |
| 29 | + t.Run(tt.name, func(t *testing.T) { |
| 30 | + provider := &ErgoToErgoExtractionBridge{ |
| 31 | + config: tt.fields.config, |
| 32 | + configured: tt.fields.configured, |
| 33 | + ergClientSource: tt.fields.ergClientSource, |
| 34 | + ergClientTarget: tt.fields.ergClientTarget, |
| 35 | + } |
| 36 | + if err := provider.Configure(tt.args.config); (err != nil) != tt.wantErr { |
| 37 | + t.Errorf("ErgoToErgoExtractionBridge.Configure() error = %v, wantErr %v", err, tt.wantErr) |
| 38 | + } |
| 39 | + }) |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +func TestErgoToErgoExtractionBridge_ExtractReverseTransferRequest(t *testing.T) { |
| 44 | + type fields struct { |
| 45 | + config ConfigureCommand |
| 46 | + configured bool |
| 47 | + ergClientSource *helpers.ErgClient |
| 48 | + ergClientTarget *helpers.ErgClient |
| 49 | + } |
| 50 | + type args struct { |
| 51 | + ctx context.Context |
| 52 | + } |
| 53 | + tests := []struct { |
| 54 | + name string |
| 55 | + fields fields |
| 56 | + args args |
| 57 | + want *extractors.Data |
| 58 | + wantErr bool |
| 59 | + }{ |
| 60 | + {name: "simple", fields: fields{}, args: args{ctx: context.Background()}, wantErr: false}, |
| 61 | + } |
| 62 | + for _, tt := range tests { |
| 63 | + t.Run(tt.name, func(t *testing.T) { |
| 64 | + provider := &WavesToEthereumExtractionBridge{} |
| 65 | + cmd := ConfigureCommand{ |
| 66 | + SourceDecimals: 9, |
| 67 | + DestinationDecimals: 9, |
| 68 | + SourceNodeUrl: "http://176.9.65.58:9016", |
| 69 | + DestinationNodeUrl: "http://176.9.65.58:9016", |
| 70 | + IBPortAddress: "import", |
| 71 | + LUPortAddress: "luport", |
| 72 | + } |
| 73 | + |
| 74 | + provider.Configure(cmd) |
| 75 | + _, err := provider.ExtractReverseTransferRequest(tt.args.ctx) |
| 76 | + if (err != nil) != tt.wantErr { |
| 77 | + t.Errorf("ErgoToErgoExtractionBridge.ExtractReverseTransferRequest() error = %v, wantErr %v", err, tt.wantErr) |
| 78 | + return |
| 79 | + } |
| 80 | + }) |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +func TestErgoToErgoExtractionBridge_ExtractDirectTransferRequest(t *testing.T) { |
| 85 | + type fields struct { |
| 86 | + config ConfigureCommand |
| 87 | + configured bool |
| 88 | + ergClientSource *helpers.ErgClient |
| 89 | + ergClientTarget *helpers.ErgClient |
| 90 | + } |
| 91 | + type args struct { |
| 92 | + ctx context.Context |
| 93 | + } |
| 94 | + tests := []struct { |
| 95 | + name string |
| 96 | + fields fields |
| 97 | + args args |
| 98 | + want *extractors.Data |
| 99 | + wantErr bool |
| 100 | + }{ |
| 101 | + {name: "simple", fields: fields{}, args: args{ctx: context.Background()}, wantErr: false}, |
| 102 | + } |
| 103 | + for _, tt := range tests { |
| 104 | + t.Run(tt.name, func(t *testing.T) { |
| 105 | + provider := &WavesToEthereumExtractionBridge{} |
| 106 | + cmd := ConfigureCommand{ |
| 107 | + SourceDecimals: 9, |
| 108 | + DestinationDecimals: 9, |
| 109 | + SourceNodeUrl: "http://176.9.65.58:9016", |
| 110 | + DestinationNodeUrl: "http://176.9.65.58:9016", |
| 111 | + IBPortAddress: "import", |
| 112 | + LUPortAddress: "luport", |
| 113 | + } |
| 114 | + |
| 115 | + provider.Configure(cmd) |
| 116 | + _, err := provider.ExtractDirectTransferRequest(tt.args.ctx) |
| 117 | + if (err != nil) != tt.wantErr { |
| 118 | + t.Errorf("ErgoToErgoExtractionBridge.ExtractDirectTransferRequest() error = %v, wantErr %v", err, tt.wantErr) |
| 119 | + return |
| 120 | + } |
| 121 | + }) |
| 122 | + } |
| 123 | +} |
0 commit comments