Compare commits
	
		
			2 Commits
		
	
	
		
			6f2a65dac9
			...
			698740e20a
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					698740e20a | ||
| 
						 | 
					940a8d395c | 
@@ -7,3 +7,9 @@
 | 
				
			|||||||
Replace "Get" by "get" in messages.pb.go
 | 
					Replace "Get" by "get" in messages.pb.go
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    gomobile bind -target android -androidapi=19
 | 
					    gomobile bind -target android -androidapi=19
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Look at the exported API and cry...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Other option
 | 
				
			||||||
 | 
					    GOOS=android GOARCH=arm64 go build -buildmode=c-archive -o libmeow.a
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,9 +35,9 @@ type Config struct {
 | 
				
			|||||||
	DbSuffix string `json:"db_suffix,omitempty"`
 | 
						DbSuffix string `json:"db_suffix,omitempty"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Inner
 | 
						// Inner
 | 
				
			||||||
	memoryPassword      string    `json:"memory_password,omitempty"`
 | 
						memoryPassword      string
 | 
				
			||||||
	additionalPasswords []string  `json:"additional_passwords,omitempty"`
 | 
						additionalPasswords []string
 | 
				
			||||||
	me                  *Identity `json:"me,omitempty"`
 | 
						me                  *Identity
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var instance *Config
 | 
					var instance *Config
 | 
				
			||||||
@@ -82,6 +82,14 @@ func (c *Config) GetMemPass() string {
 | 
				
			|||||||
	return c.memoryPassword
 | 
						return c.memoryPassword
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *Config) GetIdentity() *Identity {
 | 
				
			||||||
 | 
						return c.me
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *Config) SetIdentity(id *Identity) {
 | 
				
			||||||
 | 
						c.me = id
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *Config) SaveIdentity() error {
 | 
					func (c *Config) SaveIdentity() error {
 | 
				
			||||||
	return c.me.Save()
 | 
						return c.me.Save()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,9 +38,35 @@ func TestStoreMessage(t *testing.T) {
 | 
				
			|||||||
			panic(err)
 | 
								panic(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestGetLastMessages(t *testing.T) {
 | 
					func TestManyStoreMessage(t *testing.T) {
 | 
				
			||||||
 | 
						id := createId()
 | 
				
			||||||
 | 
						for i := 1; i < 100; i++ {
 | 
				
			||||||
 | 
							var um meowlib.UserMessage
 | 
				
			||||||
 | 
							um.Data = []byte(randomLenString(20, 200))
 | 
				
			||||||
 | 
							err := StoreMessage(&id.Peers[0], &um, GetConfig().memoryPassword)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								log.Fatal(err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						messages, err := GetLastMessages(&id.Peers[0], 0, 0, 10, GetConfig().memoryPassword)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.Fatal(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						// Checks
 | 
				
			||||||
 | 
						assert.Equal(t, len(messages), 10, "not 10 message")
 | 
				
			||||||
 | 
						// Cleanup
 | 
				
			||||||
 | 
						if exists("test.id") {
 | 
				
			||||||
 | 
							os.Remove("test.id")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						files, err := filepath.Glob("*.sqlite")
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							panic(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						for _, f := range files {
 | 
				
			||||||
 | 
							if err := os.Remove(f); err != nil {
 | 
				
			||||||
 | 
								panic(err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user