mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-10-31 17:25:06 +03:00 
			
		
		
		
	Add tests
This commit is contained in:
		
							parent
							
								
									451fbd32c3
								
							
						
					
					
						commit
						341c1ec7d7
					
				
					 1 changed files with 18 additions and 0 deletions
				
			
		|  | @ -1,6 +1,7 @@ | ||||||
| package address | package address | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"crypto/ed25519" | ||||||
| 	"math/rand" | 	"math/rand" | ||||||
| 	"testing" | 	"testing" | ||||||
| ) | ) | ||||||
|  | @ -50,3 +51,20 @@ func TestAddress_Subnet_IsValid(t *testing.T) { | ||||||
| 		t.Fatal("valid subnet marked as invalid") | 		t.Fatal("valid subnet marked as invalid") | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | func TestAddress_AddrForKey(t *testing.T) { | ||||||
|  | 	publicKey := ed25519.PublicKey{ | ||||||
|  | 		189, 186, 207, 216, 34, 64, 222, 61, 205, 18, 57, 36, 203, 181, 82, 86, | ||||||
|  | 		251, 141, 171, 8, 170, 152, 227, 5, 82, 138, 184, 79, 65, 158, 110, 251, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	gotAddress := AddrForKey(publicKey) | ||||||
|  | 
 | ||||||
|  | 	expectedAddress := Address{ | ||||||
|  | 		2, 0, 132, 138, 96, 79, 187, 126, 67, 132, 101, 219, 141, 182, 104, 149, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if *gotAddress != expectedAddress { | ||||||
|  | 		t.Fatal("invalid address returned") | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alex Kotov
						Alex Kotov